unitxt.task module

class unitxt.task.Task(data_classification_policy: List[str] = None, _requirements_list: List[str] | Dict[str, str] = [], caching: bool = None, apply_to_streams: List[str] = None, dont_apply_to_streams: List[str] = None, input_fields: Dict[str, Any] | Dict[str, str] | List[str] | NoneType = None, reference_fields: Dict[str, Any] | Dict[str, str] | List[str] | NoneType = None, inputs: Dict[str, Any] | Dict[str, str] | List[str] | NoneType = None, outputs: Dict[str, Any] | Dict[str, str] | List[str] | NoneType = None, metrics: List[str] = __required__, prediction_type: Any | str | NoneType = None, augmentable_inputs: List[str] = [], defaults: Dict[str, Any] | NoneType = None)[source]

Bases: InstanceOperator, ArtifactFetcherMixin

Task packs the different instance fields into dictionaries by their roles in the task.

input_fields

Dictionary with string names of instance input fields and types of respective values. In case a list is passed, each type will be assumed to be Any.

Type:

Union[Dict[str, str], List[str]]

reference_fields

Dictionary with string names of instance output fields and types of respective values. In case a list is passed, each type will be assumed to be Any.

Type:

Union[Dict[str, str], List[str]]

metrics

List of names of metrics to be used in the task.

Type:

List[str]

prediction_type

Need to be consistent with all used metrics. Defaults to None, which means that it will be set to Any.

Type:

Optional[str]

defaults

An optional dictionary with default values for chosen input/output keys. Needs to be consistent with names and types provided in ‘input_fields’ and/or ‘output_fields’ arguments. Will not overwrite values if already provided in a given instance.

Type:

Optional[Dict[str, Any]]

The output instance contains three fields:

“input_fields” whose value is a sub-dictionary of the input instance, consisting of all the fields listed in Arg ‘input_fields’. “reference_fields” – for the fields listed in Arg “reference_fields”. “metrics” – to contain the value of Arg ‘metrics’

augmentable_inputs: List[str] = []
unitxt.task.parse_string_types_instead_of_actual_objects(obj)[source]