Skip to content

Commit 213eda8

Browse files
committed
also debugging the judge
1 parent 9d5bd30 commit 213eda8

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

src/lighteval/metrics/metrics_sample.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,8 @@ def __init__(
10031003
backend_options=backend_options,
10041004
)
10051005

1006-
def compute(self, response: list[ModelResponse], doc: list[Doc], **kwargs) -> list:
1006+
def compute(self, **kwargs) -> list:
1007+
# When deriving: Use model_responses/docs for batched eval, model_response/doc for non batched eval
10071008
raise NotImplementedError("This method should be implemented in the subclass.")
10081009

10091010

@@ -1017,14 +1018,12 @@ def __init__(self):
10171018
short_judge_name="gpt4o",
10181019
)
10191020

1020-
def compute(self, response: list[ModelResponse], doc: list[Doc], **kwargs) -> list:
1021+
def compute(self, responses: list[ModelResponse], docs: list[Doc], **kwargs) -> list:
10211022
"""Compute the score of a generative task using a llm as a judge.
10221023
The generative task can be multiturn with 2 turns max, in that case, we
10231024
return scores for turn 1 and 2. Also returns user_prompt and judgement
10241025
which are ignored later by the aggregator.
10251026
"""
1026-
docs = as_list(doc)
1027-
responses = as_list(response)
10281027
questions = [formatted_doc.query for formatted_doc in docs]
10291028
options = [formatted_doc.choices for formatted_doc in docs]
10301029
golds = [formatted_doc.get_golds()[0] for formatted_doc in docs]
@@ -1054,12 +1053,13 @@ def compute(self, model_response: list[ModelResponse], doc: list[Doc], **kwargs)
10541053
"""
10551054
import json
10561055

1056+
model_responses = as_list(model_response)
10571057
docs = as_list(doc)
10581058

10591059
# If we are evaluating a multiturn task, we need to have specific field in the formatted doc
10601060
questions = [doc.specific["multi_turn_queries"] for doc in docs]
10611061
golds = [doc.specific.get("reference", None) for doc in docs]
1062-
predictions = [response.text[0] for response in model_response]
1062+
predictions = [response.text[0] for response in model_responses]
10631063

10641064
query_context_1 = {"query": questions[0], "context": ""}
10651065
query_context_2 = {"query": questions[1], "context": predictions[0]}
@@ -1080,19 +1080,16 @@ def compute(self, model_response: list[ModelResponse], doc: list[Doc], **kwargs)
10801080

10811081

10821082
class JudgeLLMMixEval(JudgeLLM):
1083-
def compute(self, model_response: list[ModelResponse], doc: list[Doc], **kwargs):
1083+
def compute(self, responses: list[ModelResponse], docs: list[Doc], **kwargs):
10841084
"""Compute the score of a generative task using a llm as a judge.
10851085
The generative task can be multiturn with 2 turns max, in that case, we
10861086
return scores for turn 1 and 2. Also returns user_prompt and judgement
10871087
which are ignored later by the aggregator.
10881088
"""
1089-
docs = as_list(doc)
1090-
model_responses = as_list(model_response)
1091-
10921089
questions = [doc.specific["question"] for doc in docs]
10931090
options = [doc.choices for doc in docs]
10941091
golds = [doc.get_golds()[0] for doc in docs]
1095-
predictions = [response.text[0] for response in model_responses]
1092+
predictions = [response.text[0] for response in responses]
10961093

10971094
scores, messages, judgements = self.judge.evaluate_answer_batch(questions, predictions, options, golds)
10981095

src/lighteval/tasks/extended/mix_eval/main.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ def process_judge_response_freeform_gpt(x):
115115
corpus_level_fn={
116116
"judge_score_flow": np.mean,
117117
},
118+
batched_compute=True,
118119
)
119120

120121
llm_judge_mixeval_multichoice_gpt_judge = SampleLevelMetricGrouping(
@@ -131,6 +132,7 @@ def process_judge_response_freeform_gpt(x):
131132
corpus_level_fn={
132133
"judge_score_gpt-3.5": np.mean,
133134
},
135+
batched_compute=True,
134136
)
135137

136138

@@ -152,6 +154,7 @@ def mean_dv_5(x):
152154
corpus_level_fn={
153155
"judge_score_flow": mean_dv_5,
154156
},
157+
batched_compute=True,
155158
)
156159

157160
llm_judge_mixeval_freeform_gpt_judge = SampleLevelMetricGrouping(
@@ -168,6 +171,7 @@ def mean_dv_5(x):
168171
corpus_level_fn={
169172
"judge_score_gpt-3.5": np.mean,
170173
},
174+
batched_compute=True,
171175
)
172176

173177

0 commit comments

Comments
 (0)