in src/setfit/training_args.py [0:0]
def __post_init__(self) -> None:
# Set `self.embedding_batch_size` and `self.classifier_batch_size` using values from `self.batch_size`
if isinstance(self.batch_size, int):
self.batch_size = (self.batch_size, self.batch_size)
# Set `self.embedding_num_epochs` and `self.classifier_num_epochs` using values from `self.num_epochs`
if isinstance(self.num_epochs, int):
self.num_epochs = (self.num_epochs, self.num_epochs)
# Set `self.body_embedding_learning_rate` and `self.body_classifier_learning_rate` using
# values from `self.body_learning_rate`
if isinstance(self.body_learning_rate, float):
self.body_learning_rate = (self.body_learning_rate, self.body_learning_rate)
if self.warmup_proportion < 0.0 or self.warmup_proportion > 1.0:
raise ValueError(
f"warmup_proportion must be greater than or equal to 0.0 and less than or equal to 1.0! But it was: {self.warmup_proportion}"
)
if self.report_to in (None, "all", ["all"]):
self.report_to = get_available_reporting_integrations()
elif not isinstance(self.report_to, list):
self.report_to = [self.report_to]
if self.logging_dir is None:
self.logging_dir = default_logdir()
self.logging_strategy = IntervalStrategy(self.logging_strategy)
if self.evaluation_strategy is not None:
logger.warning(
"The `evaluation_strategy` argument is deprecated and will be removed in a future version. "
"Please use `eval_strategy` instead."
)
self.eval_strategy = self.evaluation_strategy
self.eval_strategy = IntervalStrategy(self.eval_strategy)
if self.eval_steps is not None and self.eval_strategy == IntervalStrategy.NO:
logger.info('Using `eval_strategy="steps"` as `eval_steps` is defined.')
self.eval_strategy = IntervalStrategy.STEPS
# eval_steps has to be defined and non-zero, fallbacks to logging_steps if the latter is non-zero
if self.eval_strategy == IntervalStrategy.STEPS and (self.eval_steps is None or self.eval_steps == 0):
if self.logging_steps > 0:
self.eval_steps = self.logging_steps
else:
raise ValueError(
f"evaluation strategy {self.eval_strategy} requires either non-zero `eval_steps` or"
" `logging_steps`"
)
# Sanity checks for load_best_model_at_end: we require save and eval strategies to be compatible.
if self.load_best_model_at_end:
if self.eval_strategy != self.save_strategy:
raise ValueError(
"`load_best_model_at_end` requires the save and eval strategy to match, but found\n- Evaluation "
f"strategy: {self.eval_strategy}\n- Save strategy: {self.save_strategy}"
)
if self.eval_strategy == IntervalStrategy.STEPS and self.save_steps % self.eval_steps != 0:
raise ValueError(
"`load_best_model_at_end` requires the saving steps to be a round multiple of the evaluation "
f"steps, but found {self.save_steps}, which is not a round multiple of {self.eval_steps}."
)
# logging_steps must be non-zero for logging_strategy that is other than 'no'
if self.logging_strategy == IntervalStrategy.STEPS and self.logging_steps == 0:
raise ValueError(f"Logging strategy {self.logging_strategy} requires non-zero `logging_steps`")
if self.samples_per_label != 2:
logger.warning("The `samples_per_label` argument is deprecated and will be removed in a future version.")