One interface for supervised, RLHF, and parameter-efficient training
NOTE
These instructions target Linux with a Python virtual environment and GPU-enabled PyTorch. Run install and training steps in the activated venv unless noted otherwise.
Confirm that your hardware platform has the required components installed and accessible.
nvcc --version
nvidia-smi
python3 --version
git --version
Expected output should show a supported CUDA toolkit, GPU summary from nvidia-smi, Python 3, and Git.
python3 -m venv factoryEnv
source ./factoryEnv/bin/activate
Install PyTorch, torchvision, and torchaudio with CUDA 13.0 support from the official PyTorch index.
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu130
Confirm that PyTorch can see the GPU.
python -c "import torch; print(f'PyTorch: {torch.__version__}, CUDA: {torch.cuda.is_available()}')"
Expected output should show a PyTorch version and CUDA: True.
git clone --depth 1 https://github.com/hiyouga/LLaMA-Factory.git
cd LLaMA-Factory
Install LLaMA Factory in editable mode with metrics support.
pip install -e ".[metrics]"
Examine the provided LoRA fine-tuning configuration for Qwen3.
cat examples/train_lora/qwen3_lora_sft.yaml
NOTE
Log in to Hugging Face Hub to download the model if the model is gated.
hf auth login # if the model is gated
llamafactory-cli train examples/train_lora/qwen3_lora_sft.yaml
Example output:
***** train metrics *****
epoch = 3.0
total_flos = 11076559GF
train_loss = 0.9993
train_runtime = 0:14:32.12
train_samples_per_second = 3.749
train_steps_per_second = 0.471
Figure saved at: saves/qwen3-4b/lora/sft/training_loss.png
Verify that training completed successfully and checkpoints were saved.
ls -la saves/qwen3-4b/lora/sft/
Expected output should show:
checkpoint-411 or similar)adapter_config.jsonllamafactory-cli chat examples/inference/qwen3_lora_sft.yaml
# Type: "Hello, how can you help me today?"
# Expect: Response showing fine-tuned behavior
llamafactory-cli export examples/merge_lora/qwen3_lora_sft.yaml
WARNING
This will delete all training progress and checkpoints in the cloned repository and remove the virtual environment.
deactivate
cd ..
rm -rf LLaMA-Factory/
rm -rf factoryEnv/