Important
NeMo 2.0 is an experimental feature and currently released in the dev container only: nvcr.io/nvidia/nemo:dev. Please refer to NeMo 2.0 overview for information on getting started.
Parameter-Efficient Fine-Tuning (PEFT)
The following instructions explain how to fine-tune and evaluate a T5 model using PEFT.
Fine-Tune with PEFT
This section explains how to fine-tune with the NeMo Launcher and configure training.
Fine-Tune with NeMo Launcher
To run finetuning with PEFT, first update
conf/config.yaml
:
defaults:
- peft: t5/squad
stages:
- peft
Then, execute the launcher pipeline:
python3 main.py
Configure Training
You can find default configurations for PEFT with squad in conf/peft/t5/squad.yaml
.
Fine-tuning configuration is divided into four sections run
, trainer
, exp_manger
and model
.
Configure the training metadata:
run:
name: peft_t5_220m
time_limit: "04:00:00"
dependency: "singleton"
convert_name: convert_nemo
model_train_name: t5_220m
convert_dir: ${base_results_dir}/${peft.run.model_train_name}/${peft.run.convert_name}
task_name: "squad"
results_dir: ${base_results_dir}/${.model_train_name}/peft_${.task_name}
Set the number of nodes and devices for fine-tuning:
trainer:
num_nodes: 1
devices: 8
Set the path to the checkpoint from which to restore the model:
model:
restore_from_path: ${peft.run.convert_dir}/results/megatron_t5.nemo
restore_from_path
sets the path to the .nemo
checkpoint to run fine-tuning.
Set the PEFT-specific configuration:
model:
peft:
peft_scheme: "lora"
peft_scheme
sets the fine-tuning scheme to be used. Supported schemes include: lora, adapter, ia3, ptuning.
Evaluate with PEFT
Evaluate with NeMo Launcher
To run evaluating PEFT, first update
conf/config.yaml
:
defaults:
- evaluation: peft_t5/squad
stages:
- evaluation
Then, execute the launcher pipeline:
python3 main.py
.
Configure Evaluation
You can find the default configurations for PEFT with squad in conf/evaluation/peft_t5/squad.yaml
.
Set the path to checkpoint to restore model from.
model:
restore_from_path: ${peft.run.convert_dir}/results/megatron_t5.nemo
restore_from_path
sets the path to the .nemo
checkpoint to run fine-tuning.
Set PEFT specific configruation and path to the PEFT weights file to restore from.
model:
peft:
peft_scheme: "lora"
restore_from_path: ${base_results_dir}/${.model_train_name}/peft_${.task_name}
peft_scheme
sets the fine-tuning scheme to be used.
restore_from_path
sets the path to the .nemo
PEFT weights checkpoint.