📄 Multi Label

This is multi label text classification task. The set of ‘classes’ we want to classify to is provided as a list of strings.

The ‘text_type’ is an optional field that defines the type of text we classify (e.g. “document”, “review”, etc.). This can be used by the template to customize the prompt.

The ‘type_of_class’ is a field that the defines the type of classes (e.g. “emotions”, “risks”)

The ‘classes’ , ‘type_of_classes’ and ‘text_type’ should be the same on all instances.

The expected output is a list of classes that correspond to the given text (could be an empty list. The default reported metrics are the classical f1_micro, f1_macro and accuracy.

tasks.classification.multi_label

type: Task
input_fields: 
  text: str
  text_type: str
  classes: List[str]
  type_of_classes: str
reference_fields: 
  labels: List[str]
prediction_type: List[str]
metrics: 
  - metrics.f1_micro_multi_label
  - metrics.accuracy
  - metrics.f1_macro_multi_label
augmentable_inputs: 
  - text
defaults: 
  text_type: text
  type_of_classes: classes
default_template: templates.classification.multi_label.title
[source]

Explanation about Task

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

Args:
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’

References: templates.classification.multi_label.title, metrics.f1_micro_multi_label, metrics.f1_macro_multi_label, metrics.accuracy

Read more about catalog usage here.