(
ckpt_dir: str,
param_size: int = 13,
ntrain: int = 5,
few_shot: bool = False,
cot: bool = False,
subject: str = "operating_system",
max_seq_len: int = 2048,
)
| 81 | |
| 82 | |
| 83 | def main( |
| 84 | ckpt_dir: str, |
| 85 | param_size: int = 13, |
| 86 | ntrain: int = 5, |
| 87 | few_shot: bool = False, |
| 88 | cot: bool = False, |
| 89 | subject: str = "operating_system", |
| 90 | max_seq_len: int = 2048, |
| 91 | ): |
| 92 | evaluator = load( |
| 93 | ckpt_dir, |
| 94 | param_size=param_size, |
| 95 | ntrain=ntrain, |
| 96 | max_seq_len=max_seq_len |
| 97 | ) |
| 98 | |
| 99 | subject_name = subject |
| 100 | run_date = time.strftime('%Y-%m-%d_%H-%M-%S', time.localtime(time.time())) |
| 101 | save_result_dir = os.path.join( |
| 102 | r"logs", f"LLaMA_{param_size}{'_CoT' if cot else ''}_{run_date}") |
| 103 | os.makedirs(save_result_dir, exist_ok=True) |
| 104 | |
| 105 | local_rank, _ = setup_model_parallel() |
| 106 | if local_rank == 0: |
| 107 | print(f"Start evaluating {subject_name}") |
| 108 | |
| 109 | val_file_path = os.path.join('data/val', f'{subject_name}_val.csv') |
| 110 | val_df = pd.read_csv(val_file_path) |
| 111 | |
| 112 | if few_shot: |
| 113 | dev_file_path = os.path.join('data/dev', f'{subject_name}_dev.csv') |
| 114 | dev_df = pd.read_csv(dev_file_path) |
| 115 | correct_ratio = evaluator.eval_subject( |
| 116 | subject_name, |
| 117 | val_df, |
| 118 | dev_df, |
| 119 | few_shot=few_shot, |
| 120 | save_result_dir=save_result_dir, |
| 121 | cot=cot, |
| 122 | **generate_args |
| 123 | ) |
| 124 | else: |
| 125 | correct_ratio = evaluator.eval_subject( |
| 126 | subject_name, |
| 127 | val_df, |
| 128 | save_result_dir=save_result_dir, |
| 129 | cot=cot, |
| 130 | **generate_args |
| 131 | ) |
| 132 | |
| 133 | if local_rank == 0: |
| 134 | print("Acc:", correct_ratio) |
| 135 | |
| 136 | |
| 137 | if __name__ == "__main__": |
nothing calls this directly
no test coverage detected