Shroedingercat's picture
[Nikita's AI] Add examples, MANIFEST.json and SHA256SUMS for the v0.1-preview files
12e6aff verified
Raw History Blame Contribute Delete
1.3 kB
"""Load every configuration of Doubting MS MARCO and print a few rows.
Usage: python load.py [REPO_OR_FOLDER] [--rows N]
REPO_OR_FOLDER is the Hugging Face repository id or the local folder of the package (default: the folder above this
file). Needs `pip install datasets`.
"""
import argparse
import os
from datasets import load_dataset
CONFIGS = {"qrels": ["train", "dev"], "judgments": ["train", "dev"], "train_queries": ["train"],
"dev_queries": ["dev"], "generated_answers": ["train"]}
def main():
ap = argparse.ArgumentParser()
ap.add_argument("repo", nargs="?", default=os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
ap.add_argument("--rows", type=int, default=3)
ap.add_argument("--streaming", action="store_true", help="stream instead of downloading or caching whole splits")
a = ap.parse_args()
for config, splits in CONFIGS.items():
for split in splits:
ds = load_dataset(a.repo, config, split=split, streaming=a.streaming)
size = "streamed" if a.streaming else f"{ds.num_rows:,} rows"
print(f"== {config} / {split}: {size}")
for i, row in enumerate(ds):
if i >= a.rows:
break
print(row)
if __name__ == "__main__":
main()