(args)
| 216 | return score, invalid_outputs |
| 217 | |
| 218 | def main(args): |
| 219 | |
| 220 | path_split = args.pretrained_path.split('/') |
| 221 | if path_split[-1] == '': |
| 222 | path_split.pop(-1) |
| 223 | model_name = path_split[-1] |
| 224 | infer_path = os.path.join('results', model_name, 'gsm8k/infer') |
| 225 | os.makedirs(infer_path, exist_ok=True) |
| 226 | eval_path = os.path.join('results', model_name, 'gsm8k/eval') |
| 227 | os.makedirs(eval_path, exist_ok=True) |
| 228 | |
| 229 | model = load(args) |
| 230 | |
| 231 | run_infer(model, args.max_seq_len, args.data_dir, infer_path, args.overwrite) |
| 232 | |
| 233 | torch.distributed.barrier() |
| 234 | if torch.distributed.get_rank() == 0: |
| 235 | |
| 236 | score, invalid_outputs = run_eval(infer_path) |
| 237 | |
| 238 | with open(os.path.join(eval_path, 'run_results.json'), 'w') as f: |
| 239 | json.dump(score, f, ensure_ascii=False, indent=2) |
| 240 | |
| 241 | with open(os.path.join(eval_path, 'debug_invalid_outputs.jsonl'), 'w') as outfile: |
| 242 | for entry in invalid_outputs: |
| 243 | json.dump(entry, outfile, ensure_ascii=False,indent=2) |
| 244 | outfile.write('\n') |
| 245 | |
| 246 | if __name__ == "__main__": |
| 247 |
no test coverage detected