@@ -105,26 +105,32 @@ def make_judgment(
105
105
answer_df = pd .read_json (answer_file , lines = True )
106
106
107
107
# Join to get questions with answers
108
+ join_columns = ["question_id" , "choices" , "turns" , "category" ]
109
+ if bench_name == "mt_bench_branch" :
110
+ join_columns .append ("qna_file" )
111
+
108
112
joined_df = question_df .join (
109
113
answer_df .set_index ("question_id" ), on = "question_id" , rsuffix = "_answer"
110
- )[[ "question_id" , "choices" , "turns" , "category" ] ]
114
+ )[join_columns ]
111
115
# Join to get scores
116
+ join_columns .append ("score" )
112
117
joined_df = judgment_df_all .join (
113
118
joined_df .set_index ("question_id" ), on = "question_id" , lsuffix = "_judgment"
114
- )[[ "question_id" , "choices" , "turns" , "score" , "category" ] ]
119
+ )[join_columns ]
115
120
joined_df = joined_df [joined_df ["score" ] != - 1 ]
116
121
117
122
qa_pairs = []
118
123
for _ , row in joined_df .iterrows ():
119
- qa_pairs .append (
120
- {
121
- "question_id" : row ["question_id" ],
122
- "score" : row ["score" ],
123
- "category" : row ["category" ],
124
- "question" : row ["turns" ],
125
- "answer" : row ["choices" ],
126
- }
127
- )
124
+ qa_pair = {
125
+ "question_id" : row ["question_id" ],
126
+ "score" : row ["score" ],
127
+ "category" : row ["category" ],
128
+ "question" : row ["turns" ],
129
+ "answer" : row ["choices" ],
130
+ }
131
+ if bench_name == "mt_bench_branch" :
132
+ qa_pair ["qna_file" ] = row ["qna_file" ]
133
+ qa_pairs .append (qa_pair )
128
134
return overall_score , qa_pairs , turn_scores
129
135
130
136
0 commit comments