Task¶
This section contains the API reference for the distilabel
tasks.
For more information on how the Task
works and see some examples, check the Tutorial - Task page.
_Task
¶
Bases: _Step
, ABC
_Task is an abstract class that implements the _Step
interface and adds the
format_input
and format_output
methods to format the inputs and outputs of the
task. It also adds a llm
attribute to be used as the LLM to generate the outputs.
Attributes:
Name | Type | Description |
---|---|---|
llm |
LLM
|
the |
group_generations |
bool
|
whether to group the |
add_raw_output |
RuntimeParameter[bool]
|
whether to include a field with the raw output of the LLM in the
|
num_generations |
RuntimeParameter[int]
|
The number of generations to be produced per input. |
Source code in src/distilabel/steps/tasks/base.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
|
format_output(output, input=None)
abstractmethod
¶
Abstract method to format the outputs of the task. It needs to receive an output
as a string, and generates a Python dictionary with the outputs of the task. In
addition the input
used to generate the output is also received just in case it's
needed to be able to parse the output correctly.
Source code in src/distilabel/steps/tasks/base.py
load()
¶
Task
¶
Task is a class that implements the _Task
abstract class and adds the Step
interface to be used as a step in the pipeline.
Attributes:
Name | Type | Description |
---|---|---|
llm |
the |
|
group_generations |
whether to group the |
|
num_generations |
The number of generations to be produced per input. |
Source code in src/distilabel/steps/tasks/base.py
format_input(input)
abstractmethod
¶
Abstract method to format the inputs of the task. It needs to receive an input as a Python dictionary, and generates an OpenAI chat-like list of dicts.
Source code in src/distilabel/steps/tasks/base.py
process(inputs)
¶
Processes the inputs of the task and generates the outputs using the LLM.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inputs |
StepInput
|
A list of Python dictionaries with the inputs of the task. |
required |
Yields:
Type | Description |
---|---|
StepOutput
|
A list of Python dictionaries with the outputs of the task. |