trinity.common.workflows package#
Subpackages#
Submodules#
- trinity.common.workflows.agentscope_workflow module
- trinity.common.workflows.customized_math_workflows module
- trinity.common.workflows.customized_toolcall_workflows module
- trinity.common.workflows.eval_workflow module
- trinity.common.workflows.math_rm_workflow module
- trinity.common.workflows.math_ruler_workflow module
- trinity.common.workflows.math_trainable_ruler_workflow module
- trinity.common.workflows.rubric_judge_workflow module
- trinity.common.workflows.simple_mm_workflow module
- trinity.common.workflows.step_wise_workflow module
- trinity.common.workflows.workflow module
TaskWorkflowWorkflow.auxiliary_model_wrappersWorkflow.auxiliary_modelsWorkflow.can_resetWorkflow.can_repeatWorkflow.is_asyncWorkflow.__init__()Workflow.auxiliary_modelsWorkflow.resettableWorkflow.repeatableWorkflow.asynchronousWorkflow.reset()Workflow.set_repeat_times()Workflow.run()Workflow.run_async()
MultiTurnWorkflowBaseSimpleWorkflowSimpleWorkflowAsyncSimpleWorkflowMathWorkflowAsyncMathWorkflow
Module contents#
Workflow module
- class trinity.common.workflows.Task(workflow: ~typing.Type[~trinity.common.workflows.workflow.Workflow] | None = None, repeat_times: int | None = None, format_args: ~trinity.common.config.FormatConfig = <factory>, rollout_args: ~trinity.common.config.GenerationConfig = <factory>, workflow_args: dict = <factory>, reward_fn_args: dict = <factory>, is_eval: bool = False, reward_fn: ~typing.Type[~trinity.common.rewards.reward_fn.RewardFn] | None = None, raw_task: dict | None = None, batch_id: int | str = '', task_id: int | str = '', index: dict = <factory>)[source]#
Bases:
dictA Task class that defines a task and its associated reward function / workflow.
- repeat_times: int | None = None#
- format_args: FormatConfig#
- rollout_args: GenerationConfig#
- workflow_args: dict#
- reward_fn_args: dict#
- is_eval: bool = False#
- raw_task: dict | None = None#
- batch_id: int | str = ''#
- task_id: int | str = ''#
- index: dict#
- to_workflow(model: ModelWrapper, auxiliary_models: List[ModelWrapper] | None = None) Workflow[source]#
Convert the task to a workflow.
- Parameters:
model (ModelWrapper) – The rollout model for the workflow.
auxiliary_models (List[ModelWrapper]) – The auxiliary model wrappers. Workflows can access both the ModelWrapper and OpenAI client via self.auxiliary_model_wrappers and self.auxiliary_models respectively.
- Returns:
The generated workflow object.
- Return type:
- property task_desc: str | None#
- property truth: str | None#
- __init__(workflow: ~typing.Type[~trinity.common.workflows.workflow.Workflow] | None = None, repeat_times: int | None = None, format_args: ~trinity.common.config.FormatConfig = <factory>, rollout_args: ~trinity.common.config.GenerationConfig = <factory>, workflow_args: dict = <factory>, reward_fn_args: dict = <factory>, is_eval: bool = False, reward_fn: ~typing.Type[~trinity.common.rewards.reward_fn.RewardFn] | None = None, raw_task: dict | None = None, batch_id: int | str = '', task_id: int | str = '', index: dict = <factory>) None#
- class trinity.common.workflows.Workflow(*, task: Task, model: ModelWrapper, auxiliary_models: List[ModelWrapper] | None = None)[source]#
Bases:
objectThe base workflow class.
A workflow is a runnable object which generates a list of experiences.
- auxiliary_model_wrappers#
List of ModelWrapper instances for auxiliary models.
- auxiliary_models#
List of OpenAI clients (sync or async based on is_async) for auxiliary models.
- can_reset: bool = False#
- can_repeat: bool = False#
- is_async: bool = False#
- __init__(*, task: Task, model: ModelWrapper, auxiliary_models: List[ModelWrapper] | None = None)[source]#
- property resettable#
Deprecated, use cls.can_reset instead.
- property repeatable#
Deprecated, use cls.can_repeat instead. A workflow is repeatable if it can be run multiple times within the run() or run_async() method.
- property asynchronous#
Deprecated, use cls.is_async instead. Whether the workflow runs in async mode.
- set_repeat_times(repeat_times: int, run_id_base: int) None[source]#
Set the number of times to repeat the workflow. :param repeat_times: number of times to repeat the workflow (if repeatable). :type repeat_times: int :param run_id_base: base run_id for setting run_id in experiences. :type run_id_base: int
- run() List[Experience][source]#
Run workflow and return a list of experiences.
- async run_async() List[Experience][source]#
Run workflow in async and return a list of experiences.