Skip to content

[需求]新增MRCR 1M数据集 #513

Closed

Description

@Keithwwa

问题/痛点描述

问题/痛点描述

1. 背景与动机(Background & Motivation)

openai/mrcr(https://huggingface.co/datasets/openai/mrcr,MIT 协议)是 OpenAI 随 GPT-4.1 发布的长上下文多针检索(multiple needle in a haystack)基准,灵感来自 Gemini 团队的 MRCR 评测(arXiv:2409.12640)。任务形式:模型读入一段最长约 1M token 的多轮合成对话,其中同一写作请求(如 "write a poem about tapirs")以 2/4/8 次重复隐藏在同分布的干扰请求中(所有 assistant 回复均由 gpt4o 生成,针与干草堆不可区分),模型最终被要求返回第 N 次出现的实例,并在答案前拼接指定随机串:

"Prepend aYooSG8CQg to the 2nd (1 indexed) poem about tapirs.
 Do not include any other text in your response."

官方评测协议为:

  1. 将数据集中的原始多轮 prompt(JSON 编码的消息列表)原样发送至 chat 接口,不附加任何采样参数(即 OpenAI 默认 temperature=1.0);
  2. 规则评分:响应必须以 random_string_to_prepend 开头,否则记 0 分;通过后双方剥离前缀,计算 SequenceMatcher(None, response, answer).ratio();
  3. 最终得分为所有样本 ratio 的平均值,无 LLM 裁判。

数据按 needle 数分为 2needle / 4needle / 8needle 三个子集,每个子集按 prompt+answer 的 o200k_base token 数划分为 8 个 bin([4096, 8192] 至 (524288, 1048576],左开右闭),每 bin 100 条样本,全量约 2400 条(8needle 全量约 800 条)。

此前 aisbench 不支持该数据集,用户无法在框架内复现官方结果,也无法对齐 DeepSeek-V4 等技术报告中 "MRCR 1M"(8needle 全部 8 个 bin 平均)的公开口径。本 RFC 提出在 aisbench 中完整接入 MRCR 数据集的加载、推理与评测能力。

2. 目标与非目标(Goals & Non-Goals)

2.1 目标

  • 支持 mrcr_1m_gen 数据集的加载、推理(infer)、评测(eval)全流程。
  • 评测逻辑与官方 grade() 逐行对齐,保证 score 结果与官方脚本一致。
  • 支持按 needle 子集(subset)与 token bin(length_bin)灵活切片。
  • 随 PR 补充单元测试与中英文文档。

2.2 非目标

  • 不引入 LLM 裁判评测(官方为规则评分,与 corpusqa 等 LLM-judge 数据集不同)。
  • 不新增框架级机制与第三方强依赖(tiktoken 仅作为无预计算 token 列时的可选回退,懒加载)。
  • 不实现断点续跑等执行层增强(沿用框架现有 infer/eval 机制)。

建议方案

建议方案

3. 需求分析与约束(Requirements & Constraints)

约束项 说明
数据格式 Parquet 分片,按 needle 数存放于 2needle/、4needle/、8needle/ 子目录;列含 prompt(JSON 编码的多轮消息)/ answer(已含前缀的金标针文本)/ random_string_to_prepend / n_chars / date_added 等
单行体积 prompt 最长约 5.6M 字符(≈1M token),需按 row-group 流式读取,避免整片载入内存
推理接口 官方脚本使用 chat 接口,messages = json.loads(row["prompt"]) 原样发送,对应 aisbench 的 vllm_api_general_chat
推理参数 官方不传采样参数(OpenAI 默认 temperature=1.0);本地 vLLM 的 generation_config 可能默认 temperature=0.0,需显式设置 1.0 防止静默偏离;官方不限 max_tokens(针答案约 1K token,thinking 模型还需为推理 token 预留预算,建议 ≥8192 或使用服务端默认)
评测协议 纯规则评分:startswith(random_string) 门控(失败记 0)→ 双方剥离前缀 → SequenceMatcher.ratio();无答案提取、无内容后处理、无裁判
bin 定义 官方按 prompt+answer 的 o200k_base token 数分 bin,边界 [4096,8192] … (524288,1048576],左开右闭
thinking 模型 aisbench 保存的 prediction 拼接了推理内容与最终答案,startswith(前缀) 门控必然失败,评分必须使用不含推理的 content 字段

4. 总体方案(Overview)

在 aisbench 现有"gen 数据集 + chat API 模型 + 规则评分 evaluator"框架内接入 MRCR,复用框架的模板 section 机制与 API 模型基类,不新增框架级新机制(与 corpusqa 的差异:无 LLM-judge 阶段)。

官方 Parquet ──> MRCRDataset.load(流式读取 + 官方 bin 过滤)
            ──> MRCRPromptTemplate(原始多轮 prompt 透传 + 角色映射)
            ──> vllm_api_general_chat(VLLMCustomAPIChat,temperature=1.0 对齐官方)
            ──> mrcr_1m_gen(infer:生成答案)
            ──> MRCREvaluator(前缀门控 + SequenceMatcher 比对,规则评分)
            ──> score = 100 × mean(ratio)(另报 prefix_hit_rate / strict_acc / details)

5. 详细设计(Detailed Design)

5.1 数据加载:MRCRDataset.load

  • 按 row-group(iter_batches)流式扫描 parquet 分片,1M 长上下文样本不会整片载入内存。
  • subset 参数选择 needle 子目录;length_bin 参数按官方边界 (lo, hi] 过滤 bin,None 关闭过滤(全量,即 DeepSeek-V4 "MRCR 1M" 口径:8needle 全部 8 个 bin 的平均,均匀 bin 下全样本均值等于逐 bin 宏平均)。
  • token 计数优先使用数据集中预计算列(num_tokens/n_tokens/tokens/token_count),缺失时回退 tiktoken o200k_base 现算(与官方一致);离线环境给出 tiktoken 缓存预热指引(TIKTOKEN_CACHE_DIR),或以 length_bin=None 跳过过滤。
  • _parse_row:JSON 解码 prompt 并校验非空、answer/random_string_to_prepend 归一化为 str;使用顺序行号作为 id,保证 eval 阶段 prediction 与 test_set 对齐(评分需逐样本读取前缀列)。
  • 非法行告警跳过;length_bin 拼写错误、子目录/分片缺失、过滤后为空均在加载期快速失败。

5.2 提示模板:MRCRPromptTemplate

  • 官方多轮消息(OpenAI 风格 role/content)原样透传,角色映射:system -> SYSTEM、user -> HUMAN、assistant -> BOT。
  • 全部消息置于单个扁平 begin 段:绕过 API 解析器的轮次切分(_split_rounds 要求 HUMAN/BOT 严格交替,而 MRCR 存在连续 user 轮,会触发 MODEL-DATA-002)。
  • assistant 轮固定 generate=False:解析器在首个 generate=True 角色处停止构造 prompt,此处全部 assistant 轮均为对话上下文而非待生成轮。
  • 连续同角色消息按解析器行为以 \n 预合并,保证分组确定、可测试;保留消息中的额外字段。

5.3 配置:mrcr_1m_gen.py

  • 定义 mrcr_reader_cfg / mrcr_infer_cfg,绑定 MRCRDataset + MRCRPromptTemplate,推理模型使用 vllm_api_general_chat(VLLMCustomAPIChat)。
  • 定义 mrcr_eval_cfg:绑定 MRCREvaluator 与恒等后处理器 mrcr_postprocess(预测原文直接评分,与官方一致);无 judge_infer_cfg。
  • 数据集项 mrcr_1m:path='ais_bench/datasets/MRCR'、subset='8needle'、length_bin=None。

5.4 评测:MRCREvaluator

  • _grade 逐行复刻官方 grade()(含 Python 3.8 兼容的 _remove_prefix)。
  • 响应选择:优先使用推理结果文件中单独持久化的 content 字段(thinking 模型),回退 prediction(非 thinking 模型/旧结果文件);兼容 pass@k 列表载荷。
  • 逐样本前缀取自数据集 random_string_to_prepend 列(预测文件不保存该字段)。
  • 指标:score(100 × mean ratio,官方口径)、prefix_hit_rate(诊断 0 分来源)、strict_acc(ratio==1.0 精确复现率)、num_total、details(支持离线重评);预测/参考长度不一致返回 error。

5.5 参数对齐与 thinking 模型适配

  • 推理显式设置 temperature=1.0,覆盖 vLLM generation_config 可能内置的 temperature=0.0 默认值,对齐官方 OpenAI 默认。
  • max_out_len 给足预算(≥8192)或不设上限:官方不限输出,针文本约 1K token,但 thinking 模型的推理 token 计入输出,预算不足会截断最终答案导致前缀门控失败。
  • GenInferencerOutputHandler 在模型输出含推理内容时,额外持久化不含推理的 content 字段,供 MRCR 等必须对"chat API 实际返回文本"评分的 evaluator 使用。

6. 兼容性分析(Compatibility)

  • 纯新增数据集与配置,对既有数据集、模型、评测流程无影响,无向后不兼容变更。
  • GenInferencerOutputHandler 新增 content 字段为向后兼容修改(仅在存在推理内容时写入,原字段不变)。
  • tiktoken 为懒加载可选依赖,无预计算列且离线不可用时给出明确指引而非崩溃。

7. 测试与验证(Testing & Validation)

7.1 单元测试

新增 tests/UT/datasets/test_mrcr.py,覆盖:

  • MRCRDataset.load:bin 边界过滤(左开右闭)、非法 length_bin 报错、子目录/分片缺失报错、非法行跳过、顺序 id、length_bin=None 全量路径。
  • MRCRPromptTemplate.generate_item:多轮消息角色映射、扁平 begin 段结构、连续同角色合并、BOT 轮 generate=False、纯字符串 prompt、非 dict 消息容错、额外字段保留。
  • MRCREvaluator:前缀门控(缺前缀记 0)、ratio 计算、content 优先于 prediction、pass@k 列表载荷、prefix_hit_rate/strict_acc、长度不一致 error、空输入。
  • mrcr_postprocess:恒等性。

7.2 真实执行验证

ais_bench -m infer --models vllm_api_general_chat --datasets mrcr_1m_gen --num-prompts 50
ais_bench -m eval  --models vllm_api_general_chat --datasets mrcr_1m_gen --num-prompts 50

验证要点:eval 阶段 num_total == 50(与 --num-prompts 一致);推理参数按 5.5 节对齐(temperature=1.0、max_out_len 给足);score 与官方口径适配脚本(scripts/mrcr_official_eval.py,逐字节复刻官方 grade)在相同输入与参数下一致。

7.3 CI

PR 触发 run-ut-on-pr-py 工作流运行全量 UT(含覆盖率门禁)。

8. 文档更新(Documentation)

  • docs/source_zh_cn/get_started/datasets.md:LLM 类数据集表格新增 mrcr 行。
  • docs/source_en/get_started/datasets.md:LLM Datasets 表格新增 mrcr 行。
  • 新增 ais_bench/benchmark/configs/datasets/mrcr/README.md 与 README_en.md(数据集简介、openai/mrcr 下载与 ais_bench/datasets/MRCR 部署方式、subset/length_bin 切片说明、temperature=1.0 与 max_out_len 参数对齐注意事项、可用任务)。

9. 风险与开放问题(Risks & Open Questions)

  • 顺序截断风险:--num-prompts 按顺序截断时可能只覆盖首个 bin(分片有序),部分跑分的 score 不具代表性;对齐公开报告需全量运行(8needle 约 800 条、单条最高 1M token,成本高),文档需显著说明。
  • thinking 模型输出预算:推理 token 计入 max_tokens,预算不足时最终答案被截断、前缀门控直接失败,score 被低估;建议结合 finish_reason 观测。
  • tiktoken 离线可用性:bin 过滤在无预计算列时依赖在线获取 BPE 词表,离线机器需预置 TIKTOKEN_CACHE_DIR。
  • 数据版本:openai/mrcr 于 2025-12 发布 bugfix 修订(date_added 字段标注重传样本),复现历史报告时需固定数据版本。
  • 1M bin 样本要求服务端上下文窗口 ≥1M 且单请求时延长,是否需要框架级断点续跑作为开放问题。

10. 参考(References)

备选方案

  • 在框架外维护独立评测脚本(官方 snippet 的本地适配版,如 scripts/mrcr_official_eval.py):可与官方逐字节一致并支持断点续跑,但游离于 aisbench 统一的部署、并发、结果聚合与报告链路之外,且无 UT/文档覆盖,仅作为交叉验证工具保留。
  • 采用 LLM-judge 评测:与官方规则评分协议不符,结果不可与公开报告对比,弃用。

预期价值

可支持模型 1M 长序列多针检索(multi-needle co-reference)能力的标准化精度测评,评分口径与 OpenAI 官方及 DeepSeek-V4 等技术报告的 "MRCR 1M" 直接可比。

参与意向

  • 我愿意参与此功能的开发或测试

Activity

  1. added
    enhancement
    on Sep 2, 2026
  2. github-actions commented on Sep 2, 2026

    @github-actions

    🌟欢迎给AISBench benchmark测评工具提新特性诉求,请确保在issue中描述清晰,以便仓库维护者能准确理解您的诉求。对于新特性诉求仓库维护者一般会在3天内给您答复。

  3. github-actions commented on Sep 2, 2026

    @github-actions

    🤖 基于AI机器人的issue内容完整性检查结果:

    问题内容检查结果

    检查状态

    PASS

    详细检查

    • 问题/痛点描述: COMPLETE
    • 建议方案: COMPLETE
    • 预期价值: COMPLETE

    改进建议

    所有内容已完备!

    补充说明

    该 GitHub Issue 内容非常详尽和专业。尽管“问题/痛点描述”和“建议方案”的标题在正文中出现了重复,但其后紧跟着的“1. 背景与动机”、“3. 需求分析与约束”、“4. 总体方案”和“5. 详细设计”等章节提供了充分且高质量的信息,完全覆盖了这些所需部分的内容。整体结构清晰,信息量充足,符合要求。

    👉 如果想重新检查,在评论区@issue_checker即可。

    【强烈推荐❤️‍🔥】确保issue描述完整后,可以试着将issue交给Ask DeepWiki回答,deepwiki包含了和工具相关的所有知识库

  4. added
    content_check_passed
    on Sep 2, 2026
  5. Keithwwa commented on Sep 2, 2026

    @Keithwwa
    CollaboratorAuthor

    官方脚本魔改版:

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    """MRCR official evaluation runner (local-model adaptation, configurable).
    
    Faithful port of the "How to run" snippet from the openai/mrcr dataset card
    (https://huggingface.co/datasets/openai/mrcr), extended with:
    
    - OpenAI-compatible sampling parameters (temperature / top_p / top_k /
      max_tokens / seed / ...) so local vLLM/MindIE services can be aligned
      with either the official default (temperature=1.0) or a custom setting.
    - Multi-worker concurrency (official snippet is sequential; --workers N).
    - Checkpoint/resume: per-sample scores appended to a JSONL file, reruns
      skip finished samples (800 x 1M-token requests are expensive).
    - Per-bin breakdown via the precomputed n_chars column (approximate).
    
    Official semantics kept byte-for-byte:
    - messages = json.loads(row["prompt"]) posted verbatim
    - grade(): startswith(random_string_to_prepend) gate, then
      SequenceMatcher(None, response, answer).ratio()
    
    Usage:
        python scripts/mrcr_official_eval.py \
            --base-url http://127.0.0.1:8000/v1 \
            --data-dir ais_bench/datasets/MRCR/8needle \
            --temperature 1.0 --workers 8
    """
    
    import argparse
    import glob
    import json
    import os
    import sys
    from concurrent.futures import ThreadPoolExecutor, as_completed
    from difflib import SequenceMatcher
    from typing import Tuple
    
    import pandas as pd
    from openai import OpenAI
    
    
    # ---------------------------------------------------------------------------
    # Official grade() -- verbatim from the dataset card
    # ---------------------------------------------------------------------------
    
    def grade(response: str, answer: str, random_string_to_prepend: str) -> float:
        """Compare response and answer (official implementation)."""
        if not response.startswith(random_string_to_prepend):
            return 0
        response = response.removeprefix(random_string_to_prepend)
        answer = answer.removeprefix(random_string_to_prepend)
        return float(SequenceMatcher(None, response, answer).ratio())
    
    
    # ---------------------------------------------------------------------------
    # Request construction with configurable sampling parameters
    # ---------------------------------------------------------------------------
    
    def build_sampling_kwargs(args, max_len: int) -> Tuple[dict, dict]:
        """Sampling parameters for chat.completions.create.
    
        Returns (kwargs, extra_body):
        - kwargs: parameters in the OpenAI SDK's typed create() signature
          (temperature / top_p / max_tokens / seed).  Anything else raises
          "got an unexpected keyword argument".
        - extra_body: vLLM-specific parameters (chat_template_kwargs, top_k,
          repetition_penalty, ignore_eos, ...) merged verbatim into the JSON
          body via the SDK's extra_body escape hatch -- the ONLY way to pass
          params the SDK does not know about.
    
        Defaults match the official snippet's effective values: the snippet
        passes NO sampling parameter, i.e. OpenAI API defaults
        (temperature=1.0, top_p=1.0, unlimited max_tokens).  temperature is
        sent explicitly so that a vLLM generation_config default (e.g. some
        models ship temperature=0.0) cannot silently deviate from the official
        1.0.
        """
        kwargs = {}
        if args.temperature is not None:
            kwargs["temperature"] = args.temperature
        if args.top_p is not None:
            kwargs["top_p"] = args.top_p
        if args.seed is not None:
            kwargs["seed"] = args.seed
        # max_tokens: official does not limit output; answers are needle texts
        # (<= ~4k chars ≈ 1k+ tokens).  Default max_len=4096 is generous
        # enough to never truncate while bounding runaway generations.
        kwargs["max_tokens"] = args.max_tokens or max_len
    
        extra_body = {}
        if args.top_k is not None:
            extra_body["top_k"] = args.top_k
        if args.repetition_penalty is not None:
            extra_body["repetition_penalty"] = args.repetition_penalty
        if args.extra:
            extra_body.update(json.loads(args.extra))
        return kwargs, extra_body
    
    
    def load_dataset_rows(args) -> pd.DataFrame:
        shards = sorted(glob.glob(os.path.join(args.data_dir, "*.parquet")))
        if not shards:
            sys.exit(f"No .parquet shards under {args.data_dir}")
        frames = [pd.read_parquet(s) for s in shards]
        df = pd.concat(frames, ignore_index=True)
        if args.limit:
            df = df.head(args.limit)
        return df
    
    
    def eval_one(client, model, row, sampling_kwargs, extra_body=None, retries=2):
        """Run one sample; returns (index, score, response, error, details).
    
        details carries the fields needed for offline failure attribution:
        prefix/answer (regrade experiments), finish_reason (truncation),
        usage (reasoning-vs-answer token split for thinking models).
        """
        messages = json.loads(row["prompt"])  # posted verbatim, as official
        last_err = None
        for _ in range(retries + 1):
            try:
                completion = client.chat.completions.create(
                    model=model,
                    messages=messages,
                    extra_body=extra_body or {},
                    **sampling_kwargs,
                )
                choice = completion.choices[0]
                response = choice.message.content or ""
                score = grade(response, row["answer"], row["random_string_to_prepend"])
                usage = getattr(completion, "usage", None)
                details = {
                    "finish_reason": choice.finish_reason,
                    "prompt_tokens": getattr(usage, "prompt_tokens", None) if usage else None,
                    "completion_tokens": getattr(usage, "completion_tokens", None) if usage else None,
                    "prefix": row["random_string_to_prepend"],
                    "answer": row["answer"],
                }
                return row.name, score, response, None, details
            except Exception as exc:  # noqa: BLE001 - retry any transport error
                last_err = exc
        return row.name, 0.0, "", str(last_err), {}
    
    
    def main():
        parser = argparse.ArgumentParser(
            description="MRCR official eval runner (configurable sampling params)"
        )
        # Service / data
        parser.add_argument("--base-url", required=True,
                            help="e.g. http://127.0.0.1:8000/v1")
        parser.add_argument("--model", default=None,
                            help="model id served; default = first served model")
        parser.add_argument("--api-key", default="EMPTY")
        parser.add_argument("--data-dir", default="ais_bench/datasets/MRCR/8needle")
        parser.add_argument("--limit", type=int, default=0,
                            help="only evaluate first N samples (smoke test)")
        # Sampling parameters -- default: official (omit -> server default)
        parser.add_argument("--temperature", type=float, default=1.0,
                            help="official default 1.0; pass 'None' to omit")
        parser.add_argument("--top-p", type=float, default=None)
        parser.add_argument("--top-k", type=int, default=None)
        parser.add_argument("--repetition-penalty", type=float, default=None)
        parser.add_argument("--seed", type=int, default=None)
        parser.add_argument("--max-tokens", type=int, default=None,
                            help="default: 4096 (answers are ~1k tokens)")
        parser.add_argument("--extra", default=None,
                            help="JSON dict of vLLM-specific params sent via "
                                 "extra_body (NOT top-level kwargs), e.g. "
                                 "'{\"chat_template_kwargs\": {\"thinking\": true}}'")
        # Execution
        parser.add_argument("--workers", type=int, default=1,
                            help="parallel requests (official is sequential)")
        parser.add_argument("--output", default=None,
                            help="JSONL checkpoint with per-sample results")
        parser.add_argument("--timeout", type=float, default=3600.0)
        args = parser.parse_args()
    
        # Validate --extra JSON once at startup: fail fast with a clear
        # message instead of failing every request inside the loop.
        if args.extra:
            try:
                parsed = json.loads(args.extra)
                if not isinstance(parsed, dict):
                    raise ValueError("must be a JSON object")
            except Exception as exc:
                sys.exit(f"[Error] --extra is not valid JSON: {exc}\n"
                         '  Expected e.g. --extra \'{"chat_template_kwargs": '
                         '{"thinking": true}}\' (valid JSON, quoted for shell)')
    
        client = OpenAI(base_url=args.base_url, api_key=args.api_key,
                        timeout=args.timeout)
        model = args.model or client.models.list().data[0].id
        print(f"[mrcr] model={model} base_url={args.base_url}")
    
        df = load_dataset_rows(args)
        print(f"[mrcr] {len(df)} samples from {args.data_dir}")
    
        # Resume support: skip samples already scored successfully.  Error
        # records (score=0 placeholders) do NOT count as done, so a fixed
        # rerun automatically retries them.
        done = set()
        if args.output and os.path.exists(args.output):
            with open(args.output, encoding="utf-8") as fh:
                for line in fh:
                    try:
                        rec = json.loads(line)
                    except json.JSONDecodeError:
                        continue
                    if rec.get("error"):
                        continue
                    try:
                        done.add(rec["index"])
                    except KeyError:
                        continue
            print(f"[mrcr] resuming: {len(done)} samples already done")
    
        # max_tokens: official does not limit output; default to a generous
        # 4096 (needle answers are ~1k tokens) so nothing is truncated.
        sampling_kwargs, extra_body = build_sampling_kwargs(args, 4096)
        print(f"[mrcr] sampling params: {sampling_kwargs}")
        print(f"[mrcr] extra_body     : {extra_body}")
    
        if args.output:
            out_fh = open(args.output, "a", encoding="utf-8")
        else:
            out_fh = None
    
        rows = [row for _, row in df.iterrows() if row.name not in done]
        results = {}
        errors = {}
        try:
            if args.workers <= 1:
                for n, row in enumerate(rows, 1):
                    idx, score, response, err, details = eval_one(
                        client, model, row, sampling_kwargs, extra_body)
                    results[idx] = score
                    if err:
                        errors[idx] = err
                    if out_fh:
                        rec = {"index": idx, "score": score, "error": err,
                               "response": response}
                        rec.update(details)
                        out_fh.write(json.dumps(rec, ensure_ascii=False) + "\n")
                        out_fh.flush()
                    print(f"[{n}/{len(rows)}] idx={idx} score={score:.3f}"
                          + (f" ERROR={err}" if err else ""))
            else:
                with ThreadPoolExecutor(max_workers=args.workers) as pool:
                    futures = [pool.submit(eval_one, client, model, row,
                                           sampling_kwargs, extra_body)
                               for row in rows]
                    for n, fut in enumerate(as_completed(futures), 1):
                        idx, score, response, err, details = fut.result()
                        results[idx] = score
                        if err:
                            errors[idx] = err
                        if out_fh:
                            rec = {"index": idx, "score": score, "error": err,
                                   "response": response}
                            rec.update(details)
                            out_fh.write(json.dumps(rec, ensure_ascii=False) + "\n")
                            out_fh.flush()
                        print(f"[{n}/{len(rows)}] idx={idx} score={score:.3f}"
                              + (f" ERROR={err}" if err else ""))
        finally:
            if out_fh:
                out_fh.close()
    
        # Merge persisted records for the final average.  Error records
        # (score=0 placeholders) are excluded so failed samples neither
        # count against the score nor block re-running them.
        if args.output and os.path.exists(args.output):
            with open(args.output, encoding="utf-8") as fh:
                for line in fh:
                    try:
                        rec = json.loads(line)
                    except json.JSONDecodeError:
                        continue
                    if rec.get("error"):
                        continue
                    try:
                        results[rec["index"]] = rec["score"]
                    except KeyError:
                        continue
    
        scores = list(results.values())
        print("\n===== MRCR summary =====")
        print(f"samples : {len(scores)}")
        print(f"errors  : {len(errors)}")
        if scores:
            print(f"score   : {100.0 * sum(scores) / len(scores):.2f}")
        # Approximate per-bin breakdown via n_chars (chars ≈ 4x tokens).
        if "n_chars" in df.columns:
            bins = [(0, 32_768), (32_768, 131_072), (131_072, 524_288),
                    (524_288, 4_194_304)]
            labels = ["<=8k", "8k-32k", "32k-128k", "128k-1m+"]
            for (lo, hi), label in zip(bins, labels):
                sel = [results[r.name] for _, r in df.iterrows()
                       if r.name in results and lo < r["n_chars"] / 4 <= hi]
                if sel:
                    print(f"  ~{label:<8}: {100.0 * sum(sel) / len(sel):.2f}"
                          f"  (n={len(sel)})")
    
    
    if __name__ == "__main__":
        main()
    
  6. changed the title [-][需求][/-] [+][需求]新增MRCR 1M数据集[/+] on Sep 2, 2026
  7. linked a pull request that will close this issue【feature】Add mrcr 1M dataset #512on Sep 2, 2026
  8. github-actions commented on Sep 2, 2026

    @github-actions

    🤖 基于AI机器人的issue内容完整性检查结果:

    问题内容检查结果

    检查状态

    PASS

    详细检查

    • 问题/痛点描述: COMPLETE
    • 建议方案: COMPLETE
    • 预期价值: COMPLETE

    改进建议

    所有内容已完备!

    补充说明

    该GitHub Issue的内容非常详尽和专业。

    问题/痛点描述 部分通过“1. 背景与动机”详细阐述了MRCR数据集的背景、动机、任务形式、官方评测协议以及当前aisbench不支持的痛点,信息非常充足。

    建议方案 部分从“3. 需求分析与约束”开始,一直到“10. 参考”,涵盖了需求分析、总体方案、详细设计(数据加载、提示模板、配置、评测、参数对齐)、兼容性分析、测试与验证、文档更新、风险与开放问题以及备选方案,提供了极其全面的技术方案和考量,内容非常完备。

    预期价值 部分也清晰地阐明了该功能带来的价值。

    唯一的小瑕疵是“问题/痛点描述”和“建议方案”的Markdown标题(###)重复了一次,但这不影响内容的完整性。整体而言,这是一个高质量的Issue。

    👉 如果想重新检查,在评论区@issue_checker即可。

    【强烈推荐❤️‍🔥】确保issue描述完整后,可以试着将issue交给Ask DeepWiki回答,deepwiki包含了和工具相关的所有知识库

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

content_check_passedenhancement需求讨论

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions