nat.finetuning.interfaces.trajectory_builder#

Classes#

TrajectoryBuilder

Abstract interface for building trajectories from episode items.

Module Contents#

class TrajectoryBuilder(
trajectory_builder_config: nat.data_models.finetuning.TrajectoryBuilderConfig,
)#

Bases: abc.ABC

Abstract interface for building trajectories from episode items.

trajectory_builder_config#
run_config: nat.data_models.finetuning.FinetuneConfig = None#
async initialize(
run_config: nat.data_models.finetuning.FinetuneConfig,
) None#

Asynchronously initialize any resources needed for the trajectory builder.

async run_eval() nat.eval.config.EvaluationRunOutput#

Run NAT Evaluation to generate episode items for trajectory building.

Returns:

EvaluationRunOutput: The output of the evaluation run.

abstractmethod start_run(run_id: str, meta: dict | None = None) None#
Async:

Initialize any resources needed for the trajectory builder.

Args:

run_id (str): The unique identifier for the training run. meta (dict): Metadata associated with the training run.

abstractmethod finalize(
run_id: str,
meta: dict | None = None,
) nat.data_models.finetuning.TrajectoryCollection#
Async:

Finalize the trajectory building process and return the constructed trajectories.

Args:

run_id (str): The unique identifier for the training run. meta (dict): Metadata associated with the training run.

Returns:

list[Trajectory]: The list of constructed trajectories.

async compute_reward(
output_item: nat.eval.evaluator.evaluator_model.EvalOutputItem,
meta: dict | None = None,
)#

Compute reward for a given EvalOutputItem.

Args:

output_item (EvalOutputItem): The evaluation output item. meta (dict): Metadata associated with the training run.

Returns:

float: The computed reward.

abstractmethod log_progress(
run_id: str,
metrics: dict[str, Any],
output_dir: str | None = None,
) None#

Log trajectory building progress.

Args:

run_id: The training run ID metrics: Dictionary of metrics to log output_dir: Optional output directory override