Export
Inspect a collected tree and convert prepared training data into records for your trainer.
CriticSampleFactory
Section titled “CriticSampleFactory”Define a callable that converts a checkpoint context and critic target into the trainer’s critic-record type. Accept context, target, group_index, and additional metadata keywords.
The callable maps each serialized checkpoint context and direct-branch backup target into your value trainer’s input format. It handles critic records; the actor sample factory handles token sequences and advantages.
Definition
CriticSampleFactory.call
Section titled “CriticSampleFactory.call”SampleFactory
Section titled “SampleFactory”Define a callable that converts a packed actor span into a trainer-specific sample. Accept its behavior log probabilities, prepared advantage, lane, group index, and additional metadata keywords.
The first token is conditioning text and the second is generated. The factory preserves that mask, the behavior log probability, and the prepared advantage of 0.4. Its **extra parameter accepts edge and estimator metadata supplied by the exporter.
Definition
SampleFactory.call
Section titled “SampleFactory.call”format_edges
Section titled “format_edges”Format actor weights and critic targets from a prepared batch for inspection.
Inspect which segments receive positive or negative weights and which targets supervise the critic.
Definition
format_tree
Section titled “format_tree”Format the search tree, showing parent-child relationships, terminal states, rewards, and critic predictions.
Include the prepared batch to show actor weights beside their tree nodes.
Definition
to_samples
Section titled “to_samples”Convert a prepared batch into actor and critic records for a trainer. The default output is a list of dictionaries; factories can produce a trainer’s own record types.
This is what Batch.to_records() calls. The example assigns the records to prompt group 0. Each generated span becomes an actor record carrying its advantage, loss mask, and behavior log probabilities; each critic target becomes a critic record.
Definition