tasks.base_task

Tasks come above datasets in hierarchy level. In case you want to implement a new task, you need to inherit BaseTask class. You need to implement _get_available_datasets and _preprocess_item functions to complete the implementation. You can check the source to see if you need to override any other methods like prepare_batch.

Check example of VQATask here.

Example:

from pythia.tasks.base_task import BaseTask
from pythia.common.registry import registry


@registry.register_task("my")
class MyTask(BaseTask):
    def __init__(self):
        super().__init__("my")

    def _get_available_datasets(self):
        return ["my"]

    def _preprocess_item(self):
        item.text = None
        return item
class pythia.tasks.base_task.BaseTask(task_name)[source]

BaseTask that task classes need to inherit in order to create a new task.

Users must implement _get_available_datasets and _preprocess_item in order to complete implementation.

Parameters:task_name (str) – Name of the task with which it will be registered
_get_available_datasets()[source]

Set available datasets for this task here. Override in your child task class Temporary solution, later we will use decorators to easily register datasets with a task

Returns:List - List of available datasets for this particular task
_init_args(parser)[source]

Override this function to add extra parameters to parser in your child task class.

Parameters:parser (ArgumentParser) – Original parser object passed from the higher level classes like trainer
Returns:Description of returned object.
Return type:type
_preprocess_item(item)[source]

Preprocess an item to be returned from __getitem__. Override in your child task class, so you have control on what you are returning

Parameters:item (Sample) – Sample returned by a particular dataset
Returns:Preprocessed item
Return type:Sample
clean_config(config)[source]

Override this in case you want to clean the config you updated earlier in update_registry_for_model

update_registry_for_model(config)[source]

Use this if there is some specific configuration required by model which must be inferred at runtime.