命令行
您可以使用以下命令使用 examples/train_lora/qwen3_lora_sft.yaml 中的参数进行微调:
examples/train_lora/qwen3_lora_sft.yaml
llamafactory-cli train examples/train_lora/qwen3_lora_sft.yaml
也可以通过追加参数更新 yaml 文件中的参数:
llamafactory-cli train examples/train_lora/qwen3_lora_sft.yaml \ learning_rate=1e-5 \ logging_steps=1
备注
LlamaFactory 默认使用所有可见的计算设备。根据需求可通过 CUDA_VISIBLE_DEVICES 或 ASCEND_RT_VISIBLE_DEVICES 指定计算设备。
CUDA_VISIBLE_DEVICES
ASCEND_RT_VISIBLE_DEVICES
examples/train_lora/qwen3_lora_sft.yaml 提供了微调时的配置示例。该配置指定了模型参数、微调方法参数、数据集参数以及评估参数等。您需要根据自身需求自行配置。
### examples/train_lora/qwen3_lora_sft.yaml model_name_or_path: Qwen/Qwen3-4B-Instruct-2507 trust_remote_code: true stage: sft do_train: true finetuning_type: lora lora_rank: 8 lora_target: all dataset: identity,alpaca_en_demo template: qwen3_nothink cutoff_len: 2048 max_samples: 1000 preprocessing_num_workers: 16 dataloader_num_workers: 4 output_dir: saves/qwen3-4b/lora/sft logging_steps: 10 save_steps: 500 plot_loss: true overwrite_output_dir: true save_only_model: false report_to: none per_device_train_batch_size: 1 gradient_accumulation_steps: 8 learning_rate: 1.0e-4 num_train_epochs: 3.0 lr_scheduler_type: cosine warmup_ratio: 0.1 bf16: true ddp_timeout: 180000000 resume_from_checkpoint: null # eval_dataset: alpaca_en_demo # val_size: 0.1 # per_device_eval_batch_size: 1 # eval_strategy: steps # eval_steps: 500
模型 model_name_or_path 、数据集 dataset 需要存在且与 template 相对应。
model_name_or_path
dataset
template
重要训练参数
all
linear
cosine
polynomial
constant