Computes accuracy and percentage of outputs matching the format. Args: tmvp_config: Configuration object dataset: The evaluation dataset rl_cluster: Model cluster for generation. num_passes: Number of generation passes corr_lst: If True, only include correct respo
(
tmvp_config,
dataset,
rl_cluster,
num_passes=1,
corr_lst=False,
make_lst=False,
)
| 148 | |
| 149 | |
| 150 | def evaluate( |
| 151 | tmvp_config, |
| 152 | dataset, |
| 153 | rl_cluster, |
| 154 | num_passes=1, |
| 155 | corr_lst=False, |
| 156 | make_lst=False, |
| 157 | ): |
| 158 | """ |
| 159 | Computes accuracy and percentage of outputs matching the format. |
| 160 | |
| 161 | Args: |
| 162 | tmvp_config: Configuration object |
| 163 | dataset: The evaluation dataset |
| 164 | rl_cluster: Model cluster for generation. |
| 165 | num_passes: Number of generation passes |
| 166 | corr_lst: If True, only include correct responses in the list |
| 167 | make_lst: If True, return a list of (question, answer, responses) |
| 168 | |
| 169 | Returns: |
| 170 | Tuple of statistics and optionally the response list |
| 171 | """ |
| 172 | response_lst = [] |
| 173 | corr = 0 |
| 174 | partially_corr = 0 |
| 175 | corr_format = 0 |
| 176 | total = 0 |
| 177 | |
| 178 | for batch in tqdm(dataset): |
| 179 | answers = batch["answer"] |
| 180 | questions = batch["question"] |
| 181 | prompts = batch["prompts"] |
| 182 | |
| 183 | # Generate responses for all prompts in the batch |
| 184 | multiple_call_responses = generate_responses( |
| 185 | tmvp_config=tmvp_config, |
| 186 | prompts=prompts, |
| 187 | rl_cluster=rl_cluster, |
| 188 | num_passes=num_passes, |
| 189 | ) |
| 190 | |
| 191 | # Score each question-answer pair |
| 192 | for question, responses, answer in zip(questions, multiple_call_responses, answers): |
| 193 | is_correct, is_partially_correct, has_correct_format = score_responses( |
| 194 | tmvp_config=tmvp_config, |
| 195 | question=question, |
| 196 | responses=responses, |
| 197 | answer=answer, |
| 198 | ) |
| 199 | |
| 200 | # Update counters |
| 201 | if is_correct: |
| 202 | corr += 1 |
| 203 | if corr_lst and make_lst: |
| 204 | response_lst.append((question, answer, responses)) |
| 205 | else: |
| 206 | if not corr_lst and make_lst: |
| 207 | response_lst.append((question, answer, responses)) |
no test coverage detected