Skip to main content

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 checkpoints
  • per_device_train_batch_size: Training batch size per device
  • per_device_eval_batch_size: Evaluation batch size per device
  • learning_rate: Initial learning rate
  • num_train_epochs: Number of training epochs
  • max_steps: Maximum number of training steps
  • warmup_steps: Number of warmup steps
  • logging_steps: Log metrics every N steps
  • save_steps: Save checkpoint every N steps
  • eval_steps: Run evaluation every N steps
  • gradient_accumulation_steps: Number of gradient accumulation steps
  • bf16: Enable bfloat16 mixed precision
  • fp16: Enable float16 mixed precision
  • And many more…
See HuggingFace TrainingArguments documentation for the complete list.

Usage Example

CustomTrainer

CustomTrainer extends HuggingFace’s Trainer with debugging capabilities and custom distributed training setup.

Class Definition

Key Features

Sample Debugging

The training_step method prints the first 10 training samples when training begins:
This helps verify that data preprocessing is working correctly.

Custom Accelerator

The create_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 in chemlactica/custom_trainer.py