Skip to content

Commit 0ece58a

Browse files
committed
refactor: add metadata_field_name property
1 parent af5d7c6 commit 0ece58a

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

evals/eval_framework/benchmark_adapters/hotpot_qa_adapter.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ class HotpotQAAdapter(BaseBenchmarkAdapter):
1414
# distractor test: "http://curtis.ml.cmu.edu/datasets/hotpot/hotpot_dev_distractor_v1.json" delete file after changing the url
1515
}
1616

17+
def __init__(self):
18+
super().__init__()
19+
self.metadata_field_name = "level"
20+
1721
def _is_valid_supporting_fact(self, sentences: List[str], sentence_idx: Any) -> bool:
1822
"""Validates if a supporting fact index is valid for the given sentences."""
1923
return sentences and isinstance(sentence_idx, int) and 0 <= sentence_idx < len(sentences)
@@ -33,10 +37,6 @@ def _get_golden_context(self, item: dict[str, Any]) -> str:
3337

3438
return "\n".join(golden_contexts)
3539

36-
def _get_metadata_field_name(self) -> str:
37-
"""Returns the name of the metadata field used in QA pairs."""
38-
return "level"
39-
4040
def _process_item(
4141
self,
4242
item: dict[str, Any],
@@ -51,7 +51,7 @@ def _process_item(
5151
qa_pair = {
5252
"question": item["question"],
5353
"answer": item["answer"].lower(),
54-
self._get_metadata_field_name(): item[self._get_metadata_field_name()],
54+
self.metadata_field_name: item[self.metadata_field_name],
5555
}
5656

5757
if load_golden_context:

evals/eval_framework/benchmark_adapters/twowikimultihop_adapter.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ class TwoWikiMultihopAdapter(HotpotQAAdapter):
1212
"url": "https://huggingface.co/datasets/voidful/2WikiMultihopQA/resolve/main/dev.json",
1313
}
1414

15-
def _get_metadata_field_name(self) -> str:
16-
"""Returns the name of the metadata field used in QA pairs."""
17-
return "type"
15+
def __init__(self):
16+
super().__init__()
17+
self.metadata_field_name = "type"
1818

1919
def _get_golden_context(self, item: dict[str, Any]) -> str:
2020
"""Extracts and formats the golden context from supporting facts and adds evidence if available."""

0 commit comments

Comments
 (0)