Skip to content

Commit 6384835

Browse files
committed
test simpleqa judge
1 parent 51db828 commit 6384835

4 files changed

Lines changed: 23 additions & 11 deletions

File tree

src/lighteval/metrics/metrics_sample.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1167,7 +1167,7 @@ def __init__(self, k: int | None = None, **kwargs):
11671167
self.k = k
11681168
self.attribute_must_be_set = ["k"]
11691169

1170-
def compute(self, model_response: ModelResponse, doc: Doc):
1170+
def compute(self, model_response: ModelResponse, doc: Doc, **kwargs):
11711171
"""Computes the metric over a list of golds and predictions for one single sample.
11721172
It applies normalisation (if needed) to model prediction and gold, and takes the most frequent answer of all the available ones,
11731173
then compares it to the gold.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:f486ec84db5c556b13368da3317bd91629eb93f6a25f869c4972cfed61977656
3-
size 2012
2+
oid sha256:5fcce7ab58aed69f3f6bbcab853d40ab7867edc75297ce960a0bed80047d1589
3+
size 1251
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:fd3867c275c1afc6a76bdd7aa1cfc4835d4379f5e1b105167c6738a146854d48
3-
size 953
2+
oid sha256:4a64b4778c6c7f8b4a69aaf7eb269b156292eb24fff1a737266dadfb4e04a33a
3+
size 730

tests/unit/metrics/test_metrics_automated.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ class AutomatedMetricTester:
118118
"truthfulqa_mc_metrics": Metrics.truthfulqa_mc_metrics,
119119
# "faithfulness": Metrics.faithfulness, # need GPU to run
120120
# "bert_score": Metrics.bert_score, issue with the scoring function, int too big to convert
121+
# "simpleqa_judge": Metrics.simpleqa_judge, # Need to setup for compute costs
121122
"prediction_perplexity": Metrics.prediction_perplexity,
122-
# "simpleqa_judge": Metrics.simpleqa_judge, Batched metrics not supported yet
123123
"bleu": Metrics.bleu,
124124
"bleu_1": Metrics.bleu_1,
125125
"bleu_4": Metrics.bleu_4,
@@ -219,15 +219,27 @@ def run_test_case(self, test_case: MetricTestCase | CorpusLevelMetricTestCase) -
219219
doc = self.create_doc_from_dict(test_case.doc)
220220
model_response = self.create_model_response_from_dict(test_case.model_response)
221221

222-
# Create sample_params for the metric
223-
sample_params = {
224-
"doc": doc,
225-
"model_response": model_response,
226-
}
222+
# Check if this is a batched metric
223+
if hasattr(metric, "batched_compute") and metric.batched_compute:
224+
# For batched metrics, we need to pass lists of docs and responses
225+
sample_params = {
226+
"docs": [doc],
227+
"responses": [model_response],
228+
}
229+
else:
230+
# For non-batched metrics, use individual doc and model_response
231+
sample_params = {
232+
"doc": doc,
233+
"model_response": model_response,
234+
}
227235

228236
# Run the metric using the Metrics enum value
229237
actual_output = metric.compute_sample(**sample_params)
230238

239+
# For batched metrics, extract the first result since we're only testing with one sample
240+
if hasattr(metric, "batched_compute") and metric.batched_compute and isinstance(actual_output, list):
241+
actual_output = actual_output[0]
242+
231243
# Compare with expected output
232244
success = self._compare_dict_outputs(actual_output, test_case.expected_output, test_case.tolerance)
233245
return {

0 commit comments

Comments
 (0)