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

Method to_dict

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

dumps the current config as a dictionary object, as a printable format. null fields will not be printed. Used for dumping results alongside full task configuration :return: dict A printable dictionary version of the TaskConfig object. # TODO: should any

(self, keep_callable: bool = False)

Source from the content-addressed store, hash-verified

119 return setattr(self, item, value)
120
121 def to_dict(self, keep_callable: bool = False) -> dict:
122 """dumps the current config as a dictionary object, as a printable format.
123 null fields will not be printed.
124 Used for dumping results alongside full task configuration
125
126 :return: dict
127 A printable dictionary version of the TaskConfig object.
128
129 # TODO: should any default value in the TaskConfig not be printed?
130 """
131 cfg_dict = asdict(self)
132 # remove values that are `None`
133 for k, v in list(cfg_dict.items()):
134 if v is None:
135 cfg_dict.pop(k)
136 elif k == "metric_list":
137 for metric_dict in v:
138 for metric_key, metric_value in metric_dict.items():
139 if callable(metric_value):
140 metric_dict[metric_key] = self.serialize_function(
141 metric_value, keep_callable=keep_callable
142 )
143 cfg_dict[k] = v
144 elif callable(v):
145 cfg_dict[k] = self.serialize_function(v, keep_callable=keep_callable)
146 return cfg_dict
147
148 def serialize_function(
149 self, value: Union[Callable, str], keep_callable=False

Callers 1

dump_configMethod · 0.80

Calls 1

serialize_functionMethod · 0.95

Tested by

no test coverage detected