Supervised Fine-Tuning with Hugging Face
Learn about the hf_sft
function within Simplifine’s Train Engine
hf_sft(
model_name:str,
dataset_name:str='nlpie/pandemic_pact',
keys:list=[],
template:str='',
do_split:bool=True,
split_ratio:float=0.2,
load_eval_from_data:bool=False,
data:dict={},
num_epochs:int=3,
batch_size:int=1,
wandb_api_key:str='',
lr:float=5e-5,
from_hf:bool=True,
response_template:str='### Answer:',
eval_steps:int=10,
logging_steps:int=10,
use_peft:bool=False,
peft_config=None,
ddp:bool=False,
zero:bool=True,
deepspeed_config:str='home/ubuntu/src/zero_config.json',
hf_token:str='',
gradient_accumulation_steps:int=1,
fp16:bool=False,
bf16:bool=False,
report_to:str='none',
gradient_checkpointing:bool=False,
max_seq_length:int=2048,
use_wandb:bool=False,
output_dir:str='sft_output',
eval_accumulation_steps:int=8,
wandb_config:wandbConfig=None
):
The name or path of the pre-trained model to use.
The name of the dataset to use for training. Defaults to 'nlpie/pandemic_pact'
.
List of keys used for formatting prompts in the template. Defaults to an empty list.
Template string for formatting prompts with keys. Defaults to an empty string.
A flag to determine whether to split the dataset into training and validation sets. Defaults to True
.
The ratio of the dataset to be used for validation. Defaults to 0.2
.
A flag to determine whether to load evaluation data from the provided dataset. Defaults to False
.
A dictionary containing the training data. Defaults to an empty dictionary.
The number of training epochs. Defaults to 3
.
The batch size for training. Defaults to 1
.
The API key for Weights and Biases (WandB) logging. Defaults to an empty string.
The learning rate for optimization. Defaults to 5e-5
.
A flag to determine whether to load the dataset from Hugging Face. Defaults to True
.
Template string for response formatting. Defaults to '### Answer:'
.
The number of steps between evaluations. Defaults to 10
.
The number of steps between logging outputs. Defaults to 10
.
A flag to enable Parameter-Efficient Fine-Tuning (PEFT). Defaults to False
.
The configuration object for PEFT. Defaults to None
.
A flag to enable Distributed Data Parallel (DDP) training. Defaults to False
.
A flag to enable ZeRO (Zero Redundancy Optimizer) for memory optimization. Defaults to True
.
The path to the DeepSpeed configuration file. Defaults to 'home/ubuntu/src/zero_config.json'
.
The Hugging Face token required for accessing private datasets or models. Defaults to an empty string.
The number of steps for gradient accumulation. Defaults to 1
.
A flag to enable 16-bit floating-point (FP16) training. Defaults to False
.
A flag to enable 16-bit Brain Floating Point (BF16) training. Defaults to False
.
The service to report training logs to (e.g., wandb
). Defaults to 'none'
.
A flag to enable gradient checkpointing for reducing memory usage. Defaults to False
.
The maximum sequence length for the input data. Defaults to 2048
.
A flag to enable Weights and Biases (WandB) logging. Defaults to False
.
The directory to save the output model and logs. Defaults to 'sft_output'
.
The number of steps for evaluation accumulation. Defaults to 8
.
The configuration for Weights and Biases (WandB) logging. Defaults to None
.