unitxt.task module

class unitxt.task.Task(data_classification_policy: List[str] = None, _requirements_list: List[str] | Dict[str, str] = [], requirements: 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, default_template: unitxt.templates.Template = None)[source]

Bases: InstanceOperator, ArtifactFetcherMixin

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

Parameters:
  • input_fields (Union[Dict[str, str], List[str]]) – 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.

  • reference_fields (Union[Dict[str, str], List[str]]) – 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.

  • metrics (List[str]) – List of names of metrics to be used in the task.

  • prediction_type (Optional[str]) – Need to be consistent with all used metrics. Defaults to None, which means that it will be set to Any.

  • defaults (Optional[Dict[str, Any]]) – 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.

The output instance contains three fields:
  1. “input_fields” whose value is a sub-dictionary of the input instance, consisting of all the fields listed in Arg ‘input_fields’.

  2. “reference_fields” – for the fields listed in Arg “reference_fields”.

  3. “metrics” – to contain the value of Arg ‘metrics’

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