CoolFace
Datasetpublic

leideng/longbench-v2-view

LongBench v2: Towards Deeper Understanding and Reasoning on Realistic Long-context Multitasks ๐ŸŒ Project Page: https://longbench2.github.io ๐Ÿ’ป Github Repo: https://github.com/THUDM/LongBench ๐Ÿ“š Arxiv Paper: https://arxiv.org/abs/2412.15204 LongBench v2 is designed to assess the ability of LLMs to handle long-context problems requiring deep understanding and reasoning across real-world multitasks. LongBench v2 has the following features: (1) Length: Context length ranging from 8kโ€ฆ See the full description on the dataset page: https://huggingface.co/datasets/leideng/longbench-v2-view.

sourceHugging Faceapache-2.0updated 6mo agoView on Hugging Face
0likes58downloads
split_data_by_domain.py88 linesDownload Raw Back to root
1#!/usr/bin/env python32 3import argparse4import json5import re6import unicodedata7from collections import defaultdict8from pathlib import Path9 10 11def slugify(value: str) -> str:12    normalized = unicodedata.normalize("NFKD", value)13    ascii_value = normalized.encode("ascii", "ignore").decode("ascii")14    slug = re.sub(r"[^a-zA-Z0-9]+", "-", ascii_value.lower()).strip("-")15    return slug or "unknown"16 17 18def load_records(input_path: Path) -> list[dict]:19    with input_path.open("r", encoding="utf-8") as f:20        data = json.load(f)21 22    if not isinstance(data, list):23        raise ValueError(f"{input_path} must contain a top-level JSON array.")24 25    for index, item in enumerate(data):26        if not isinstance(item, dict):27            raise ValueError(f"Record at index {index} is not a JSON object.")28 29    return data30 31 32def group_records(records: list[dict]) -> dict[tuple[str, str], list[dict]]:33    grouped: dict[tuple[str, str], list[dict]] = defaultdict(list)34 35    for index, record in enumerate(records):36        domain = record.get("domain")37        sub_domain = record.get("sub_domain")38 39        if not domain or not sub_domain:40            raise ValueError(41                f"Record at index {index} is missing a non-empty 'domain' or 'sub_domain'."42            )43 44        grouped[(str(domain), str(sub_domain))].append(record)45 46    return grouped47 48 49def write_groups(grouped_records: dict[tuple[str, str], list[dict]], output_dir: Path) -> None:50    for (domain, sub_domain), records in grouped_records.items():51        domain_dir = output_dir / slugify(domain)52        output_path = domain_dir / f"{slugify(sub_domain)}.json"53 54        domain_dir.mkdir(parents=True, exist_ok=True)55        with output_path.open("w", encoding="utf-8") as f:56            json.dump(records, f, ensure_ascii=False, indent=2)57            f.write("\n")58 59 60def parse_args() -> argparse.Namespace:61    parser = argparse.ArgumentParser(62        description="Split a JSON array into data/<domain>/<sub-domain>.json files."63    )64    parser.add_argument(65        "--input",66        type=Path,67        default=Path("data.json"),68        help="Path to the source JSON file. Default: data.json",69    )70    parser.add_argument(71        "--output-dir",72        type=Path,73        default=Path("data"),74        help="Directory where split files will be written. Default: data",75    )76    return parser.parse_args()77 78 79def main() -> None:80    args = parse_args()81    records = load_records(args.input)82    grouped_records = group_records(records)83    write_groups(grouped_records, args.output_dir)84 85 86if __name__ == "__main__":87    main()88