Skip to main content

Finetune CLI


The following are the CLI commands for ScaleGenAI Finetuning.

FunctionDescription
createLaunch a fine-tuning job.
listList launched fine-tuning jobs.
stopStop a running job.
viewView a fine-tuning job.

create

Run this command to create a finetuning job.

scalegen finetune clm create [args]

The following is the list of arguments that the command requires:

Parameter Description

  • cloud_regions:: str : Specifies the cloud region and provider to use, formatted as PROVIDER:REGION (e.g., SCALEGENAI:US).
  • gpu_num:: int : The number of GPUs to use for the job.
  • gpu_type:: str : Type of GPU to use for training (e.g., A100_80GB).
  • artifacts_storage:: str : The storage location for results (e.g., s3-store).
  • model:: str : The Hugging Face model to use for fine-tuning (e.g., "meta-llama/Meta-Llama-3.1-8B-Instruct").
  • job_name:: str : Name of the fine-tuning job.
  • hf_project_name:: str : The name of the Hugging Face project (e.g., "code_vulnerability_sequrity_dpo").
  • push_to_hub:: flag : A flag to indicate if the fine-tuned model should be pushed to the Hugging Face model hub.
  • hf_repo_id:: str : The Hugging Face repository ID for pushing the model (e.g., "username/repo").
  • data_path:: str : Path to the dataset on Hugging Face (e.g., "CyberNative/Code_Vulnerability_Security_DPO").
  • hf_token:: str : The Hugging Face authentication token.
  • comet_ml_key:: str : API key for Comet ML to enable experiment tracking.
  • finetuning_type:: str : Type of finetuning to perform (e.g., "dpo" for Direct Preference Optimization).
  • model_max_length:: int : The maximum sequence length for the model (e.g., 8192).
  • mixed_precision:: str [ "fp16" | "bf16" ] : The type of mixed precision to use (e.g., bf16).
  • lr:: float : Learning rate for training (e.g., 0.0003).
  • epochs:: int : Number of training epochs (e.g., 1).
  • batch_size:: int : Batch size for training (e.g., 2).
  • warmup_ratio:: float : The ratio of warm-up steps to total steps (e.g., 0.1).
  • gradient_accumulation_steps:: int : Number of gradient accumulation steps (e.g., 64).
  • logging_steps:: int : Number of steps between logging outputs (e.g., 1).
  • optimizer:: str [ "adamw_torch" | ... ] : Optimizer type to use (e.g., "adamw_torch").
  • lr_scheduler_type:: str [ "linear" | ... ] : Learning rate scheduler type (e.g., "linear").
  • weight_decay:: float : Weight decay value for regularization (e.g., 0.0).
  • max_grad_norm:: float : Maximum gradient norm for clipping (e.g., 1.0).
  • seed:: int : Random seed for reproducibility (e.g., 42).
  • save_steps:: int : Number of steps between model checkpoints (e.g., 20).
  • use_peft:: str [ "lora" | ... ] : Specifies if and what type of Parameter-Efficient Fine-Tuning (PEFT) to use (e.g., "lora").
  • lora_r:: int : LoRA rank parameter (e.g., 32).
  • lora_alpha:: int : LoRA alpha parameter (e.g., 64).
  • lora_dropout:: float : Dropout rate for LoRA layers (e.g., 0.05).
  • text_column:: str : The column name containing the text data (e.g., "chosen").
  • prompt_text_column:: str : The column name for prompt text (e.g., "question").
  • rejected_text_column:: str : The column name for rejected text data (e.g., "rejected").
  • use_flash_attention_2:: flag : A flag to enable Flash Attention 2 for efficient attention mechanisms.
  • max_prompt_length:: int : The maximum length of the prompt text (e.g., 256).
  • merge_adapter:: flag : A flag to merge adapter weights.
  • padding:: str [ "left" | "right" ] : Padding direction for token sequences (e.g., "left").
  • train_split:: str : The dataset split used for training (e.g., "train").
  • help

Example

scalegen finetune clm create \
--cloud_regions SCALEGENAI:US \
--gpu_num 1 \
--gpu_type A100_80GB \
--artifacts_storage s3-store \
--model "meta-llama/Meta-Llama-3.1-8B-Instruct" \
--job_name "template_code_vulnerability_sequrity_dpo" \
--hf_project_name "code_vulnerability_sequrity_dpo" \
--push_to_hub \
--hf_repo_id "username/repo" \
--data_path "CyberNative/Code_Vulnerability_Security_DPO" \
--hf_token your_hf_token \
--comet_ml_key your_cometml_key \
--finetuning_type dpo \
--model_max_length 8192 \
--mixed_precision bf16 \
--lr 0.0003 \
--epochs 1 \
--batch_size 2 \
--warmup_ratio 0.1 \
--gradient_accumulation_steps 64 \
--logging_steps 1 \
--optimizer adamw_torch \
--lr_scheduler_type linear \
--weight_decay 0.0 \
--max_grad_norm 1.0 \
--seed 42 \
--save_steps 20 \
--use_peft lora \
--lora_r 32 \
--lora_alpha 64 \
--lora_dropout 0.05 \
--text_column chosen \
--prompt_text_column question \
--rejected_text_column rejected \
--use_flash_attention_2 \
--max_prompt_length 256 \
--merge_adapter \
--padding left \
--train_split "train"

list

Run this command to list your running finetuning jobs.

scalegen finetune clm list

To list all the jobs, use the -a or --all flag

scalegen finetune clm list -a

stop

Run this command to stop a running finetuning jobs.

scalegen finetune clm stop <JOB_ID>

Example

scalegen finetune clm stop test_job

view

View the status and logs associated with a job.

scalegen finetune clm view <JOB_ID>

Example

scalegen finetune clm view test_job