BaseParamTuner Class

Overview

The BaseParamTuner class provides a framework for creating custom parameter tuners that iterate over hyperparameters to find the best configuration based on a scoring function. It supports fixed parameters, current hyperparameter values, and saving results to a file.

Evaluator

Your tuner’s evaluator will by default run the evaluator specified in Experiment according to your use case. See Evaluators for details.

Fields

ParameterTypeDefaultDescriptionRequired
param_fnCallable[[Dict[str, Any]], Any]N/AThe objective function that scores the LLM system being optimized on the specified parameters.Yes
param_dictOptional[Dict[str, Any]]NoneA dictionary of parameters to iterate over.No
fixed_param_dictOptional[Dict[str, Any]]{}A dictionary of fixed parameters passed to each job.No
current_param_dictOptional[Dict[str, Any]]{}A dictionary of current hyperparameter values.No
show_progressboolFalseFlag to show progress during tuning.No
num_promptsint1Number of prompt variations to generate for each data point.No
results_filepathOptional[str]NonePath for saving tuner run results.No

Methods

fit() -> ExperimentResult

An abstract method that should be implemented by subclasses to perform parameter tuning.

save_results_table(results: pd.DataFrame, filepath: str) -> None

Saves the results to a CSV file.

Supported Tuner Subclasses