Datasets:
Add files using upload-large-folder tool
Browse files- MixBench25.py +21 -67
MixBench25.py
CHANGED
|
@@ -101,12 +101,13 @@ import json
|
|
| 101 |
import datasets
|
| 102 |
import csv
|
| 103 |
|
| 104 |
-
_DESCRIPTION = """
|
| 105 |
-
MixBench is a benchmark for evaluating mixed-modality retrieval. It contains queries and corpora from four datasets: MSCOCO, Google_WIT, VisualNews, and OVEN.
|
| 106 |
Each subset provides: query, corpus, mixed_corpus, and qrel splits.
|
| 107 |
"""
|
| 108 |
|
| 109 |
_HOMEPAGE = "https://huggingface.co/datasets/mixed-modality-search/MixBench25"
|
|
|
|
| 110 |
_SUBSETS = ["MSCOCO", "Google_WIT", "VisualNews", "OVEN"]
|
| 111 |
|
| 112 |
class MixBenchConfig(datasets.BuilderConfig):
|
|
@@ -118,35 +119,13 @@ class MixBenchConfig(datasets.BuilderConfig):
|
|
| 118 |
class MixBench(datasets.GeneratorBasedBuilder):
|
| 119 |
BUILDER_CONFIGS = [MixBenchConfig(name=subset) for subset in _SUBSETS]
|
| 120 |
|
| 121 |
-
def _info(self):
|
| 122 |
-
# This will be overwritten per split below
|
| 123 |
-
return datasets.DatasetInfo(
|
| 124 |
-
description=_DESCRIPTION,
|
| 125 |
-
features=datasets.Features({
|
| 126 |
-
"placeholder": datasets.Value("string")
|
| 127 |
-
}),
|
| 128 |
-
homepage=_HOMEPAGE,
|
| 129 |
-
)
|
| 130 |
-
|
| 131 |
def _split_generators(self, dl_manager):
|
| 132 |
subset_dir = os.path.join(dl_manager.manual_dir or dl_manager._base_path, self.config.name)
|
| 133 |
return [
|
| 134 |
-
datasets.SplitGenerator(
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
),
|
| 138 |
-
datasets.SplitGenerator(
|
| 139 |
-
name="corpus",
|
| 140 |
-
gen_kwargs={"path": os.path.join(subset_dir, "corpus.jsonl"), "split": "corpus"},
|
| 141 |
-
),
|
| 142 |
-
datasets.SplitGenerator(
|
| 143 |
-
name="mixed_corpus",
|
| 144 |
-
gen_kwargs={"path": os.path.join(subset_dir, "mixed_corpus.jsonl"), "split": "mixed_corpus"},
|
| 145 |
-
),
|
| 146 |
-
datasets.SplitGenerator(
|
| 147 |
-
name="qrel",
|
| 148 |
-
gen_kwargs={"path": os.path.join(subset_dir, "qrels", "qrels.tsv"), "split": "qrel"},
|
| 149 |
-
),
|
| 150 |
]
|
| 151 |
|
| 152 |
def _generate_examples(self, path, split):
|
|
@@ -165,52 +144,27 @@ class MixBench(datasets.GeneratorBasedBuilder):
|
|
| 165 |
row = json.loads(line)
|
| 166 |
if split == "query":
|
| 167 |
yield idx, {
|
| 168 |
-
"query_id": row
|
| 169 |
-
"text": row
|
| 170 |
-
"image": row
|
| 171 |
}
|
| 172 |
else: # corpus or mixed_corpus
|
| 173 |
yield idx, {
|
| 174 |
-
"corpus_id": row
|
| 175 |
-
"text": row
|
| 176 |
-
"image": row
|
| 177 |
}
|
| 178 |
|
| 179 |
def _info(self):
|
| 180 |
-
|
| 181 |
return datasets.DatasetInfo(
|
| 182 |
description=_DESCRIPTION,
|
| 183 |
homepage=_HOMEPAGE,
|
| 184 |
-
features={
|
| 185 |
-
"
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
"corpus_id": datasets.Value("string"),
|
| 192 |
-
"text": datasets.Value("string"),
|
| 193 |
-
"image": datasets.Value("string"),
|
| 194 |
-
}),
|
| 195 |
-
"mixed_corpus": datasets.Features({
|
| 196 |
-
"corpus_id": datasets.Value("string"),
|
| 197 |
-
"text": datasets.Value("string"),
|
| 198 |
-
"image": datasets.Value("string"),
|
| 199 |
-
}),
|
| 200 |
-
"qrel": datasets.Features({
|
| 201 |
-
"query_id": datasets.Value("string"),
|
| 202 |
-
"corpus_id": datasets.Value("string"),
|
| 203 |
-
"score": datasets.Value("int32"),
|
| 204 |
-
}),
|
| 205 |
-
}.get(self.split_name, datasets.Features({"placeholder": datasets.Value("string")})),
|
| 206 |
)
|
| 207 |
-
|
| 208 |
-
@property
|
| 209 |
-
def split_name(self):
|
| 210 |
-
# Dynamically infer split being loaded
|
| 211 |
-
import inspect
|
| 212 |
-
outer = inspect.stack()[2]
|
| 213 |
-
if "split" in outer.frame.f_locals:
|
| 214 |
-
return outer.frame.f_locals["split"]
|
| 215 |
-
return None
|
| 216 |
-
|
|
|
|
| 101 |
import datasets
|
| 102 |
import csv
|
| 103 |
|
| 104 |
+
_DESCRIPTION = """
|
| 105 |
+
MixBench is a benchmark for evaluating mixed-modality retrieval. It contains queries and corpora from four datasets: MSCOCO, Google_WIT, VisualNews, and OVEN.
|
| 106 |
Each subset provides: query, corpus, mixed_corpus, and qrel splits.
|
| 107 |
"""
|
| 108 |
|
| 109 |
_HOMEPAGE = "https://huggingface.co/datasets/mixed-modality-search/MixBench25"
|
| 110 |
+
|
| 111 |
_SUBSETS = ["MSCOCO", "Google_WIT", "VisualNews", "OVEN"]
|
| 112 |
|
| 113 |
class MixBenchConfig(datasets.BuilderConfig):
|
|
|
|
| 119 |
class MixBench(datasets.GeneratorBasedBuilder):
|
| 120 |
BUILDER_CONFIGS = [MixBenchConfig(name=subset) for subset in _SUBSETS]
|
| 121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
def _split_generators(self, dl_manager):
|
| 123 |
subset_dir = os.path.join(dl_manager.manual_dir or dl_manager._base_path, self.config.name)
|
| 124 |
return [
|
| 125 |
+
datasets.SplitGenerator(name="query", gen_kwargs={"path": os.path.join(subset_dir, "queries.jsonl"), "split": "query"}),
|
| 126 |
+
datasets.SplitGenerator(name="corpus", gen_kwargs={"path": os.path.join(subset_dir, "corpus.jsonl"), "split": "corpus"}),
|
| 127 |
+
datasets.SplitGenerator(name="mixed_corpus", gen_kwargs={"path": os.path.join(subset_dir, "mixed_corpus.jsonl"), "split": "mixed_corpus"}),
|
| 128 |
+
datasets.SplitGenerator(name="qrel", gen_kwargs={"path": os.path.join(subset_dir, "qrels", "qrels.tsv"), "split": "qrel"}),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
]
|
| 130 |
|
| 131 |
def _generate_examples(self, path, split):
|
|
|
|
| 144 |
row = json.loads(line)
|
| 145 |
if split == "query":
|
| 146 |
yield idx, {
|
| 147 |
+
"query_id": row["query_id"],
|
| 148 |
+
"text": row["text"],
|
| 149 |
+
"image": row["image"],
|
| 150 |
}
|
| 151 |
else: # corpus or mixed_corpus
|
| 152 |
yield idx, {
|
| 153 |
+
"corpus_id": row["corpus_id"],
|
| 154 |
+
"text": row["text"],
|
| 155 |
+
"image": row["image"],
|
| 156 |
}
|
| 157 |
|
| 158 |
def _info(self):
|
| 159 |
+
# Provide all possible features but only used in relevant splits
|
| 160 |
return datasets.DatasetInfo(
|
| 161 |
description=_DESCRIPTION,
|
| 162 |
homepage=_HOMEPAGE,
|
| 163 |
+
features=datasets.Features({
|
| 164 |
+
"query_id": datasets.Value("string"),
|
| 165 |
+
"corpus_id": datasets.Value("string"),
|
| 166 |
+
"text": datasets.Value("string"),
|
| 167 |
+
"image": datasets.Value("string"),
|
| 168 |
+
"score": datasets.Value("int32"),
|
| 169 |
+
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|