Preparation
Convert a searched tree into actor advantages and critic targets. DirectBranchTd is the paper’s recipe: critic targets are direct-branch backups, and actor advantages are segment TD errors over refined values.
ActorSample
Section titled “ActorSample”Store one segment’s training tokens, masks, and scalar advantage. prepare_samples() creates these records; the trainer uses weight as the segment’s learning signal.
Definition
Fields
ActorSample.edge_tokens
Section titled “ActorSample.edge_tokens”Count trainable tokens across the entire edge. Use this to normalize by edge when a chat template splits one edge into several training spans.
The actor and critic samples one prompt produced, with collection statistics and failures. Convert it to trainer records with to_records().
Definition
Fields
Batch.len
Section titled “Batch.len”Batch.to_records
Section titled “Batch.to_records”Flatten the batch into trainer records: one per generated actor span and one per critic target. Records are dictionaries unless you pass factories for your trainer’s types. group_index identifies the prompt group; min_abs_advantage drops actor records whose advantage is too small to matter.
Batch.describe
Section titled “Batch.describe”Render each actor edge with its advantage and diagnostics, then each critic target, one per line.
CriticSample
Section titled “CriticSample”Pair a serialized checkpoint context with its target remaining return. The critic learns to predict target from context.
Definition
Fields
ESTIMATOR_KEY
Section titled “ESTIMATOR_KEY”Name the metadata field identifying the estimator that prepared a training record.
Definition
LANE_KEY
Section titled “LANE_KEY”Name the metadata field distinguishing actor records from critic records.
Definition
Restrict a training record’s destination to "actor" or "critic".
Definition
critic_targets
Section titled “critic_targets”Critic training samples: the direct-branch backup at every expanded checkpoint that was scored, paired with the context the critic read.
Definition
prepare_samples
Section titled “prepare_samples”Turn a searched tree into actor advantages and critic targets with a chosen recipe. Collector.prepare() calls this with the collector’s reward settings.
Critic targets do not depend on the recipe: every expanded checkpoint the critic scored regresses on the mean of its direct-branch backups. DirectBranchTd measures actor advantages against refined values; estimator=None prepares only critic targets.
Definition