nip.trainers.malt_pure_text._tree_iter#
- nip.trainers.malt_pure_text._tree_iter(partial_rollouts_by_level: list[list[_PartialRolloutNode]], include_level: bool = False, leaves_first: bool = False)[source]#
Iterate over the tree of responses, either downwards or upwards.
We omit the root node, because it is not a response.
- Parameters:
partial_rollouts_by_level (list[list[_PartialRolloutNode]]) – The tree of responses, stratified by level.
include_level (bool, default=False) – Whether to include the level in the output. In this case, the output is a tuple of the level and the partial rollout.
leaves_first (bool, default=False) – Whether to iterate from the leaves upwards.
- Yields:
level (int, optional) – The level in the tree of responses.
partial_rollout (_PartialRolloutNode) – The next node in the tree of responses.