(
samples: Optional[str] = None,
min_correct: int = 10,
max_profile: Optional[int] = None,
n_samples: int = 100,
temperature: float = 1.0,
parallel: Optional[int] = None,
lazy_evaluation: bool = True,
i_just_wanna_run: bool = False,
**model_kwargs,
)
| 290 | |
| 291 | # TODO(@ganler): OPTIMIZATION: reuse the samples from the generations of other datasets |
| 292 | def script( |
| 293 | samples: Optional[str] = None, |
| 294 | min_correct: int = 10, |
| 295 | max_profile: Optional[int] = None, |
| 296 | n_samples: int = 100, |
| 297 | temperature: float = 1.0, |
| 298 | parallel: Optional[int] = None, |
| 299 | lazy_evaluation: bool = True, |
| 300 | i_just_wanna_run: bool = False, |
| 301 | **model_kwargs, |
| 302 | ): |
| 303 | max_profile = max_profile or min(min_correct * 2, n_samples) |
| 304 | assert min_correct <= max_profile <= n_samples |
| 305 | simple_test_profiler() # test linux perf setup |
| 306 | |
| 307 | if model_kwargs: |
| 308 | # To suppress the warning of tokenizers |
| 309 | os.environ["TOKENIZERS_PARALLELISM"] = os.environ.get( |
| 310 | "TOKENIZERS_PARALLELISM", "false" |
| 311 | ) |
| 312 | # overwrite parameters |
| 313 | samples = run_codegen( |
| 314 | dataset="evalperf", |
| 315 | n_samples=n_samples, |
| 316 | temperature=temperature, |
| 317 | **model_kwargs, |
| 318 | ) |
| 319 | |
| 320 | assert samples is not None, "Please provide the path to the samples" |
| 321 | |
| 322 | # Data loading |
| 323 | problems, expected_output = get_evalplus_data() |
| 324 | ptasks = get_evalperf_data() |
| 325 | |
| 326 | # Parallelism |
| 327 | max_workers = parallel or max(1, default_parallelism(divisor=4)) |
| 328 | assert 0 < max_workers < multiprocessing.cpu_count(), "Invalid max CPU workers" |
| 329 | |
| 330 | if os.path.isdir(samples): |
| 331 | result_path = os.path.join(samples, "evalperf_results.json") |
| 332 | else: |
| 333 | assert samples.endswith(".jsonl") |
| 334 | result_path = samples.replace(".jsonl", "_evalperf_results.json") |
| 335 | brief_result_path = result_path.replace( |
| 336 | "evalperf_results.json", "evalperf_results.brief.json" |
| 337 | ) |
| 338 | |
| 339 | # resume results |
| 340 | eval_results = {} |
| 341 | if not i_just_wanna_run and os.path.exists(result_path): |
| 342 | resumed_result = json.load(open(result_path, "r")) |
| 343 | if ( |
| 344 | resumed_result["n_samples"] == n_samples |
| 345 | and resumed_result["temperature"] == temperature |
| 346 | and resumed_result["min_correct"] == min_correct |
| 347 | and resumed_result["max_profile"] == max_profile |
| 348 | ): |
| 349 | eval_results = resumed_result["eval"] |
nothing calls this directly
no test coverage detected
searching dependent graphs…