@@ -1003,7 +1003,8 @@ def __init__(
10031003 backend_options = backend_options ,
10041004 )
10051005
1006- def compute (self , responses : list [ModelResponse ], docs : 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
@@ -1026,7 +1027,7 @@ def compute(self, responses: list[ModelResponse], docs: list[Doc], **kwargs) ->
10261027 questions = [formatted_doc .query for formatted_doc in docs ]
10271028 options = [formatted_doc .choices for formatted_doc in docs ]
10281029 golds = [formatted_doc .get_golds ()[0 ] for formatted_doc in docs ]
1029- predictions = [response .text [0 ] for response in responses ]
1030+ predictions = [response .final_text [0 ] for response in responses ]
10301031
10311032 scores , messages , judgements = self .judge .evaluate_answer_batch (questions , predictions , options , golds )
10321033
@@ -1044,18 +1045,21 @@ def compute(self, responses: list[ModelResponse], docs: list[Doc], **kwargs) ->
10441045
10451046
10461047class JudgeLLMMTBench (JudgeLLM ):
1047- def compute (self , model_response : list [ModelResponse ], docs : list [Doc ], ** kwargs ):
1048+ def compute (self , model_response : list [ModelResponse ], doc : list [Doc ], ** kwargs ):
10481049 """Compute the score of a generative task using a llm as a judge.
10491050 The generative task can be multiturn with 2 turns max, in that case, we
10501051 return scores for turn 1 and 2. Also returns user_prompt and judgement
10511052 which are ignored later by the aggregator.
10521053 """
10531054 import json
10541055
1056+ model_responses = as_list (model_response )
1057+ docs = as_list (doc )
1058+
10551059 # If we are evaluating a multiturn task, we need to have specific field in the formatted doc
10561060 questions = [doc .specific ["multi_turn_queries" ] for doc in docs ]
10571061 golds = [doc .specific .get ("reference" , None ) for doc in docs ]
1058- predictions = [response .text [0 ] for response in model_response ]
1062+ predictions = [response .final_text [0 ] for response in model_responses ]
10591063
10601064 query_context_1 = {"query" : questions [0 ], "context" : "" }
10611065 query_context_2 = {"query" : questions [1 ], "context" : predictions [0 ]}
@@ -1076,7 +1080,7 @@ def compute(self, model_response: list[ModelResponse], docs: list[Doc], **kwargs
10761080
10771081
10781082class JudgeLLMMixEval (JudgeLLM ):
1079- def compute (self , model_responses : list [ModelResponse ], docs : list [Doc ], ** kwargs ):
1083+ def compute (self , responses : list [ModelResponse ], docs : list [Doc ], ** kwargs ):
10801084 """Compute the score of a generative task using a llm as a judge.
10811085 The generative task can be multiturn with 2 turns max, in that case, we
10821086 return scores for turn 1 and 2. Also returns user_prompt and judgement
@@ -1085,7 +1089,7 @@ def compute(self, model_responses: list[ModelResponse], docs: list[Doc], **kwarg
10851089 questions = [doc .specific ["question" ] for doc in docs ]
10861090 options = [doc .choices for doc in docs ]
10871091 golds = [doc .get_golds ()[0 ] for doc in docs ]
1088- predictions = [response .text [0 ] for response in model_responses ]
1092+ predictions = [response .final_text [0 ] for response in responses ]
10891093
10901094 scores , messages , judgements = self .judge .evaluate_answer_batch (questions , predictions , options , golds )
10911095
@@ -1094,8 +1098,8 @@ def compute(self, model_responses: list[ModelResponse], docs: list[Doc], **kwarg
10941098 metrics .append (
10951099 {
10961100 f"judge_score_{ self .short_judge_name } " : scores [i ],
1097- f"user_prompt_{ self .short_judge_name } " : messages [i ],
1098- f"judgement_{ self .short_judge_name } " : judgements [i ],
1101+ # f"user_prompt_{self.short_judge_name}": messages[i],
1102+ # f"judgement_{self.short_judge_name}": judgements[i],
10991103 }
11001104 )
11011105
0 commit comments