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
):
model_name
string
required

The name or path of the pre-trained model to use.

dataset_name
string

The name of the dataset to use for training. Defaults to 'nlpie/pandemic_pact'.

keys
list

List of keys used for formatting prompts in the template. Defaults to an empty list.

template
string

Template string for formatting prompts with keys. Defaults to an empty string.

do_split
boolean

A flag to determine whether to split the dataset into training and validation sets. Defaults to True.

split_ratio
float

The ratio of the dataset to be used for validation. Defaults to 0.2.

load_eval_from_data
boolean

A flag to determine whether to load evaluation data from the provided dataset. Defaults to False.

data
dict

A dictionary containing the training data. Defaults to an empty dictionary.

num_epochs
int

The number of training epochs. Defaults to 3.

batch_size
int

The batch size for training. Defaults to 1.

wandb_api_key
string

The API key for Weights and Biases (WandB) logging. Defaults to an empty string.

lr
float

The learning rate for optimization. Defaults to 5e-5.

from_hf
boolean

A flag to determine whether to load the dataset from Hugging Face. Defaults to True.

response_template
string

Template string for response formatting. Defaults to '### Answer:'.

eval_steps
int

The number of steps between evaluations. Defaults to 10.

logging_steps
int

The number of steps between logging outputs. Defaults to 10.

use_peft
boolean

A flag to enable Parameter-Efficient Fine-Tuning (PEFT). Defaults to False.

peft_config
object

The configuration object for PEFT. Defaults to None.

ddp
boolean

A flag to enable Distributed Data Parallel (DDP) training. Defaults to False.

zero
boolean

A flag to enable ZeRO (Zero Redundancy Optimizer) for memory optimization. Defaults to True.

deepspeed_config
string

The path to the DeepSpeed configuration file. Defaults to 'home/ubuntu/src/zero_config.json'.

hf_token
string

The Hugging Face token required for accessing private datasets or models. Defaults to an empty string.

gradient_accumulation_steps
int

The number of steps for gradient accumulation. Defaults to 1.

fp16
boolean

A flag to enable 16-bit floating-point (FP16) training. Defaults to False.

bf16
boolean

A flag to enable 16-bit Brain Floating Point (BF16) training. Defaults to False.

report_to
string

The service to report training logs to (e.g., wandb). Defaults to 'none'.

gradient_checkpointing
boolean

A flag to enable gradient checkpointing for reducing memory usage. Defaults to False.

max_seq_length
int

The maximum sequence length for the input data. Defaults to 2048.

use_wandb
boolean

A flag to enable Weights and Biases (WandB) logging. Defaults to False.

output_dir
string

The directory to save the output model and logs. Defaults to 'sft_output'.

eval_accumulation_steps
int

The number of steps for evaluation accumulation. Defaults to 8.

wandb_config
wandbConfig

The configuration for Weights and Biases (WandB) logging. Defaults to None.