@@ -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
10821082class 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
0 commit comments