Instantiate and evaluate a model on a list of tasks. :param lm: obj Language Model :param task_dict: dict[str, Task] Dictionary of tasks. Tasks will be taken to have name type(task).config.task . :param limit: int, optional Limit the number of examples per task (
(
lm,
task_dict,
limit: Optional[int] = None,
bootstrap_iters: Optional[int] = 100000,
decontamination_ngrams_path=None,
write_out: bool = False,
log_samples: bool = True,
verbosity: str = "INFO",
# additions
context_length: int = 1000,
answer_length: int = 50,
sequence_length: int = 2048,
context_key: str = "context",
answer_key: list = ["value"],
cutting_context: bool = False,
decode_mode: str = "default",
skip_check_answer: bool = False,
model_name='other',
)
| 253 | |
| 254 | @positional_deprecated |
| 255 | def evaluate( |
| 256 | lm, |
| 257 | task_dict, |
| 258 | limit: Optional[int] = None, |
| 259 | bootstrap_iters: Optional[int] = 100000, |
| 260 | decontamination_ngrams_path=None, |
| 261 | write_out: bool = False, |
| 262 | log_samples: bool = True, |
| 263 | verbosity: str = "INFO", |
| 264 | |
| 265 | # additions |
| 266 | context_length: int = 1000, |
| 267 | answer_length: int = 50, |
| 268 | sequence_length: int = 2048, |
| 269 | context_key: str = "context", |
| 270 | answer_key: list = ["value"], |
| 271 | cutting_context: bool = False, |
| 272 | decode_mode: str = "default", |
| 273 | skip_check_answer: bool = False, |
| 274 | |
| 275 | model_name='other', |
| 276 | ): |
| 277 | """Instantiate and evaluate a model on a list of tasks. |
| 278 | |
| 279 | :param lm: obj |
| 280 | Language Model |
| 281 | :param task_dict: dict[str, Task] |
| 282 | Dictionary of tasks. Tasks will be taken to have name type(task).config.task . |
| 283 | :param limit: int, optional |
| 284 | Limit the number of examples per task (only use this for testing) |
| 285 | :param bootstrap_iters: |
| 286 | Number of iterations for bootstrap statistics |
| 287 | :param write_out: bool |
| 288 | If True, write out an example document and model input for checking task integrity |
| 289 | :param log_samples: bool |
| 290 | If True, write out all model outputs and documents for per-sample measurement and post-hoc analysis |
| 291 | :return |
| 292 | Dictionary of results |
| 293 | """ |
| 294 | |
| 295 | eval_logger.setLevel(getattr(logging, f"{verbosity}")) |
| 296 | # decontaminate = decontamination_ngrams_path is not None |
| 297 | |
| 298 | for task_name, task in task_dict.items(): |
| 299 | if isinstance(task, tuple): |
| 300 | _, task = task |
| 301 | if not log_samples: |
| 302 | assert ( |
| 303 | "bypass" not in getattr(task, "_metric_fn_list", {}).keys() |
| 304 | ), f"log_samples must be True for 'bypass' only tasks: {task_name}" |
| 305 | |
| 306 | # stores the final result for each task, for each metric/filter pair. |
| 307 | results = collections.defaultdict(dict) |
| 308 | # Tracks each task's version. |
| 309 | versions = collections.defaultdict(dict) |
| 310 | # Tracks the YAML configs of all chosen tasks. |
| 311 | configs = collections.defaultdict(dict) |
| 312 | # logs info about each document evaluated. |
no test coverage detected