Overview
ChemLactica provides custom trainer implementations that extend HuggingFace Transformers’Trainer and TRL’s IterativeSFTTrainer with additional functionality for debugging, distributed training, and SLURM evaluation.
CustomArguments
CustomArguments extends TrainingArguments from HuggingFace Transformers with ChemLactica-specific parameters.
Class Definition
Parameters
bool
default:"False"
Whether to run evaluation via SLURM job submission. Enables distributed evaluation on compute clusters
str
default:"None"
The training command being executed, stored for reproducibility and debugging
str
default:"None"
Name of the experiment for tracking, logging, and checkpoint organization
str
default:"ChemLacticaTokenizer66"
Path to the tokenizer directory or model
Inherited Parameters
CustomArguments inherits all parameters from HuggingFace’s TrainingArguments, including:
output_dir: Directory to save checkpointsper_device_train_batch_size: Training batch size per deviceper_device_eval_batch_size: Evaluation batch size per devicelearning_rate: Initial learning ratenum_train_epochs: Number of training epochsmax_steps: Maximum number of training stepswarmup_steps: Number of warmup stepslogging_steps: Log metrics every N stepssave_steps: Save checkpoint every N stepseval_steps: Run evaluation every N stepsgradient_accumulation_steps: Number of gradient accumulation stepsbf16: Enable bfloat16 mixed precisionfp16: Enable float16 mixed precision- And many more…
Usage Example
CustomTrainer
CustomTrainer extends HuggingFace’s Trainer with debugging capabilities and custom distributed training setup.
Class Definition
Key Features
Sample Debugging
Thetraining_step method prints the first 10 training samples when training begins:
Custom Accelerator
Thecreate_accelerator_and_postprocess method uses CustomAccelerator instead of the standard Accelerate accelerator:
Usage Example
CustomIterativeSFTTrainer
CustomIterativeSFTTrainer extends TRL’s IterativeSFTTrainer with sample debugging for iterative SFT training.
Class Definition
Usage Example
Source Reference
Implemented inchemlactica/custom_trainer.py