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

Method __init__

lm-eval-harness/lm_eval/api/task.py:676–875  ·  view source on GitHub ↗
(
        self, data_dir=None, cache_dir=None, download_mode=None, config: dict = None
    )

Source from the content-addressed store, hash-verified

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"]
729 kwargs = {
730 key: metric_config[key]
731 for key in metric_config
732 if key
733 not in ["metric", "aggregation", "higher_is_better", "hf_evaluate"]

Callers

nothing calls this directly

Calls 15

downloadMethod · 0.95
fewshot_docsMethod · 0.95
has_test_docsMethod · 0.95
test_docsMethod · 0.95
has_validation_docsMethod · 0.95
validation_docsMethod · 0.95
doc_to_textMethod · 0.95
doc_to_targetMethod · 0.95
doc_to_choiceMethod · 0.95
get_metricFunction · 0.90
get_metric_aggregationFunction · 0.90
is_higher_betterFunction · 0.90

Tested by

no test coverage detected