(args)
| 210 | return results |
| 211 | |
| 212 | def main(args): |
| 213 | |
| 214 | path_split = args.pretrained_path.split('/') |
| 215 | if path_split[-1] == '': |
| 216 | path_split.pop(-1) |
| 217 | model_name = path_split[-1] |
| 218 | eval_path = os.path.join('results', model_name, 'ceval/eval') |
| 219 | os.makedirs(eval_path, exist_ok=True) |
| 220 | |
| 221 | model = load(args) |
| 222 | |
| 223 | result_path = os.path.join(eval_path, 'run_results.json') |
| 224 | if not args.overwrite and os.path.exists(result_path): |
| 225 | print(f"{result_path} existed, skip!") |
| 226 | return |
| 227 | |
| 228 | subjects_result = run_infer_eval(model, args.max_seq_len, args.data_dir, args.ntrain) |
| 229 | |
| 230 | torch.distributed.barrier() |
| 231 | if torch.distributed.get_rank() == 0: |
| 232 | |
| 233 | score = cal_ceval(subjects_result) |
| 234 | with open(result_path, 'w') as f: |
| 235 | json.dump(score, f, ensure_ascii=False, indent=2) |
| 236 | |
| 237 | if __name__ == "__main__": |
| 238 |
no test coverage detected