SFTTrainer is TRL’s supervised fine-tuning component. It accepts a model, tokenizer, formatted training dataset, and training configuration while automating batching, gradient computation, learning-rate scheduling, and checkpoint saving. section 2.1.2
Configure the trainer around the workload and available memory:
- Use batch size and gradient accumulation steps to control effective batch size and memory use. section 2.1.2
- Set learning rate, maximum steps, scheduler, and optimizer; adamw_8bit reduces optimizer memory usage. section 2.1.2
Credit-risk fine-tuning
A formatted credit-risk dataset trains a LoRA-adapted model with per-device batches of two, four accumulation steps, 60 maximum steps, a 2e-4 learning rate, and adamw_8bit. Testing an applicant profile produces a high-risk assessment.


