MCPcopy Create free account
hub / github.com/OpenSparseLLMs/MoM / ConfigurableTask

Class ConfigurableTask

lm-eval-harness/lm_eval/api/task.py:671–1364  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

669
670
671class ConfigurableTask(Task):
672 VERSION = "Yaml"
673 OUTPUT_TYPE = None
674 CONFIG = None
675
676 def __init__(
677 self, data_dir=None, cache_dir=None, download_mode=None, config: dict = None
678 ) -> None: # TODO no super() call here
679 # Get pre-configured attributes
680 self._config = self.CONFIG
681
682 # Use new configurations if there was no preconfiguration
683 if self.config is None:
684 self._config = TaskConfig(**config)
685 # Overwrite configs
686 else:
687 if config is not None:
688 self._config.__dict__.update(config)
689
690 if self.config is None:
691 raise ValueError(
692 "Must pass a config to ConfigurableTask, either in cls.CONFIG or `config` kwarg"
693 )
694
695 if isinstance(self.config.metadata, dict):
696 if "version" in self.config.metadata:
697 self.VERSION = self.config.metadata["version"]
698
699 if self.config.output_type is not None:
700 assert self.config.output_type in ALL_OUTPUT_TYPES
701 self.OUTPUT_TYPE = self.config.output_type
702
703 if self.config.dataset_path is not None:
704 self.DATASET_PATH = self.config.dataset_path
705
706 if self.config.dataset_name is not None:
707 self.DATASET_NAME = self.config.dataset_name
708
709 self._metric_fn_list = {}
710 self._metric_fn_kwargs = {}
711 self._aggregation_list = {}
712 self._higher_is_better = {}
713
714 if self.config.metric_list is None:
715 # TODO: handle this in TaskConfig.__post_init__ ?
716 _metric_list = DEFAULT_METRIC_REGISTRY[self.config.output_type]
717
718 for metric_name in _metric_list:
719 self._metric_fn_list[metric_name] = get_metric(metric_name)
720 self._metric_fn_kwargs[metric_name] = {}
721 self._aggregation_list[metric_name] = get_metric_aggregation(
722 metric_name
723 )
724 self._higher_is_better[metric_name] = is_higher_better(metric_name)
725 else:
726 for metric_config in self.config.metric_list:
727 assert "metric" in metric_config
728 metric_name = metric_config["metric"]

Callers 1

load_taskMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected