分支标签打开更多操作菜单

最新提交

 

历史记录

2 次提交2 次提交

文件夹和文件

名称名称最后一次提交消息最后提交日期
codecode  
constructionconstruction  
error_analysiserror_analysis  
settingssettings  
src/docgallerysrc/docgallery  
.gitignore.gitignore  
LICENSELICENSE  
README.mdREADME.md  
requirements.txtrequirements.txt  

仓库文件导航

DocGallery:诊断富文档中的多跳视觉推理

项目页面 | 论文(arXiv,即将发布)| 数据集(Hugging Face)

DocGallery 是一个用于评测富文档多跳视觉推理的基准。它包含由智能体编写的源代码渲染而成的 120 份文档,涵盖地图、手写记录、工程图纸和密集表格,平均分辨率为 7,655 × 6,106 像素;另有 932 道问题,每道都需要综合页面多个区域的证据。参考答案由程序计算得出,每道问题都附带其证据区域和中间结果。

本仓库包含用于处理页面图像、渲染提示词和对答案评分的代码,以及论文所报告每次运行使用的提示词和设置。数据(图像、问题和标注)托管在 Hugging Face 上。

目录

requirements.txt                  Pillow and jsonschema (Python 3.12)
src/docgallery/                   library: data loading, binding of predictions to questions, scorer
code/
  build_prompt.py                 renders the system message, user message and run settings of a question
  prepare_images.py               resizes a page to its recommended size and tiles it for an API
  input_meter.py                  input-token threshold T of every question for every model (library)
  input_acceptance.py             acceptance of a request by its input tokens
  evaluate.py                     scores a file of predictions
settings/
  common_parameters.json          default request parameters; models.json and qwen_budget.json replace them per model
  models.json                     thinking, effort and temperature of the 18 models (Table 5), agent of their tool runs
  qwen_budget.json                separate reasoning and answer budgets of the two Qwen models
  image_input.md                  recommended size, tiling, input-token threshold and acceptance
  recommended_sizes.json          recommended and original size of the 120 pages
  visual_token_rules.json         whole-canvas visual-token estimate of each model
  input_thresholds.json           threshold T and original-size value R of every question for every model
  answer_protocol.zh.md           answer protocol included in every prompt (verbatim)
  answer_protocol.en.md           English translation
  no_tools/                       main run without tools: configuration, system prompt, user-prompt template
  tools_codex/                    tool runs in Codex: configuration, CLI settings, instructions, user-prompt template
  tools_claude_code/              tool runs of the two Claude models in Claude Code
  budget_sweep/                   runs with output caps of 38,400 and 51,200 tokens
  question_lists/                 the 93-question tool subset, the 93 questions of the budget sweep,
                                  and the questions each model capped at 25,600 tokens
error_analysis/
  error_types.csv                 error type of every incorrect response of 11 models (Appendix A.1)
construction/                     how the documents and questions are built: method, prompts of the three stages,
                                  worked example DG004 with its two solvers, and further visual examples

位于 settings/ 下、以 .zh.txt 或 .zh.md 结尾的文件包含发送给模型的中文文本;每份文件旁边都有对应的英文翻译(.en.txt, .en.md),该翻译未发送给模型。在用户提示词模板中, {{ANSWER_PROTOCOL}}, {{QUESTION}}, {{OUTPUT_SCHEMA}} 和 {{FIELD_SPECS}} 标记了针对每道问题填充的部分。答案协议的标题包含“DocGallery120”,这是运行这些实验时该基准所使用的工作名称。

快速开始

python -m pip install -r requirements.txt
huggingface-cli download inclusionAI/DocGallery --repo-type dataset --local-dir DocGallery

# prompt and run settings of one question for one model
python code/build_prompt.py --root DocGallery --question-id DG005_Q4 --mode no_tools --model "GPT-6.1 Sol" --output out/DG005_Q4.json

# images of one page for an API whose single-image limits are 1,536 px per edge and 2,359,296 px per image (example values)
python code/prepare_images.py --source DocGallery/images/DG005/DG005.png --doc-id DG005 --max-edge 1536 --max-area 2359296 --max-images 100 --output-dir out/DG005_images

# input-token threshold of one question for one model; with --actual-tokens, the input tokens and whether they reach
# the threshold are recorded; --enforce-input-threshold turns the acceptance test on (exit status 1 when the input
# tokens are below the threshold or missing)
python code/input_acceptance.py --model "Qwen3.8-27B" --question-id DG003_Q6 --mode tools

# scoring: the reference answers, written as predictions, score 932 of 932
python code/evaluate.py --root DocGallery --predictions DocGallery/reference_answers_as_predictions.jsonl --output-dir out/scored

# scoring only the questions of a list, here the 93-question tool subset (--skip-unknown-ids ignores the other predictions)
python code/evaluate.py --root DocGallery --predictions DocGallery/reference_answers_as_predictions.jsonl --question-ids-file settings/question_lists/tool_subset_93.json --skip-unknown-ids --output-dir out/scored_tool_subset

这些脚本不会覆盖现有输出;每次运行都应指定新的 --output 或 --output-dir 。

评测设置

无工具运行(表 2)。 18 个模型回答全部 932 道问题,每道问题单独发起一次请求,上下文中不包含其他问题,每道问题仅提交一个答案。系统消息和用户消息模板位于 settings/no_tools/。用户消息会说明预算(在 24,576 个 token 内完成推理,并为最终答案至少预留 1,024 个 token)和图像顺序,随后给出答案协议、问题、输出模式及其字段约定。每个响应(包括推理)最多可输出 25,600 个 token;如果响应达到上限但没有给出最终答案,则计为错误。Qwen3.8-Max 和 Qwen3.8-27B 的 API 分别限制推理和可见答案,额度分别为 24,576 和 1,024 个 token(settings/qwen_budget.json);在无工具运行中不向它们发送推理强度参数,而其 Codex 配置将推理强度设为 xhigh。每个模型的思考模式、推理强度和温度设置均位于 settings/models.json;若某个 API 不接受温度参数,则列出其固定值。页面图像的处理方式以及每个请求如何依据输入 token 阈值进行检查,详见 settings/image_input.md.

有工具运行(表 2 和表 11)。 有工具运行时,每道问题需要进行多轮模型调用,因此比无工具运行耗费更多时间和 API 用量。为此,全部 18 个模型均在从 932 道问题中无放回均匀抽取的一个固定 93 题子集上进行了有工具运行(settings/question_lists/tool_subset_93.json),表 2 对每个模型均报告该子集的结果,从而确保所有模型在相同问题上进行比较。Claude Fable 5.2、GPT-6.1 Sol 和 Claude Opus 5.5 还在全部 932 道问题上进行了有工具运行(表 11)。

  • Codex (除两个 Claude 模型之外的所有模型; settings/tools_codex/)。使用 Codex CLI 0.148.0,每道问题单独建立一个会话,运行于配备 Python 3.12、其标准库和 Pillow 的离线环境中。工具可以运行命令、与正在运行的进程交互以及查看图像,使模型能够进行计算,并对页面图像执行裁剪、缩放或格式转换。最多允许 24 次成功的工具调用;达到上限后工具将被禁用,并保留一次请求以生成最终答案。所有轮次的推理、工具调用和最终答案均计入 25,600 个输出 token 的上限。指令文件 model_instructions.txt 会替代 Codex 的内置指令,并取代中文系统消息;用户消息则额外增加一段关于工具环境的说明。
  • Claude Code (Claude Fable 5.2 和 Claude Opus 5.5; settings/tools_claude_code/)。使用 Claude Code 2.1.292,推理强度设为 high,每道问题新建一个会话,并在同一离线环境中运行。无工具运行的系统消息会附加到 Claude Code 的内置指令之后;用户消息与无工具运行相同,并包含处理好的页面图像。模型可以使用 shell(Bash)和文件读取工具(Read);MCP 服务器和网络搜索均被禁用。与 Codex 运行一样,最多允许 24 次成功的工具调用,由测试框架负责计数,且所有轮次的输出均计入 25,600 个 token 的上限。

因此,这两个环境在智能体、所用指令和可用工具方面有所不同;工具调用次数限制和输出上限则相同。

更大预算(表 8 和附录 A.2; settings/budget_sweep/). 每个模型沿用主实验的设置;仅更改输出上限以及用户消息中声明的推理预算(37,376 或 50,176 个推理 token,另加 1,024 个用于答案的 token)。表 8 在 51,200 个 token 的预算下,重新运行腾讯 Hy4、Seed-2.1-Turbo、LongCat-2.5、Step 5 Preview 或 MiMo-V2.6-Pro 达到 25,600 token 上限的每一道问题(question_lists/capped_at_25600.json,总计 2,028 道问题)。附录 A.2 的预算扫描实验针对从三个模型均达到上限的 316 道问题中无放回均匀抽取的 93 道问题,分别在 25,600、38,400 和 51,200 个 token 的上限下运行 Seed-2.1-Turbo、腾讯 Hy4 和 LongCat-2.5(question_lists/budget_sweep_93.json).

评分

评分器(src/docgallery/scorer.py,版本 dg-scorer-1.0)是一个确定性程序;评分过程不使用任何模型。它只对最终答案进行评分,绝不会将单独的推理通道附加到答案中。

  1. 开头和结尾的 ASCII 空格、制表符及换行符会被忽略。其余内容必须能够解析为严格 JSON(不得有重复键、NaN 或 Infinity),顶层必须是满足该问题 JSON Schema 的对象。
  2. 内容。 布尔值的类型和值必须匹配;数值必须与精确的十进制值一致,不设容差(题目规定的舍入是任务的一部分);字符串须经过 Unicode NFC 规范化,且大小写、空格和字符宽度均有区别;数组须按照题目规定的顺序逐元素匹配。表示集合的数组必须按协议的规范顺序列出其成员,因此,相同成员若顺序不同也会被判为错误。
  3. 格式。 答案文本必须与协议的规范序列化结果完全一致:键按 Unicode 码点排序,词元之间不得有空白,字符串采用 NFC 规范化,除 JSON 要求的转义外不得使用其他转义,数值则须采用声明的小数位数或最短的普通形式。
  4. 只有内容和格式均正确时,一道题才得 1 分,否则得 0 分。即使值正确,只要形式不规范,例如答案置于代码围栏中、答案后附有说明,或分隔符后存在空格,也得 0 分,并记录为格式错误。无法解析的答案,例如使用单引号书写的答案,得 0 分,并记录为无效输出。
  5. 准确率等于得 1 分的题目数量除以题目总数。没有预测结果的题目按错误计。因技术原因失败的请求由调用方标记,并从分母中排除;错误、空白或被截断的答案绝不会被排除。

预测结果

预测文件每行包含一个 JSON 对象,其字段为 id, answer (原始的最终答案字符串,不进行解析)、以及 prompt_sha256, image_sha256, question_revision 和 protocol_id ,其值与 code/build_prompt.py写入的内容一致。这四个字段将答案与模型收到的问题版本绑定。可选字段: technical_failure ,其中数据集里的 failure_reason. reference_answers_as_predictions.jsonl 是一个示例。

错误类型

error_analysis/error_types.csv 给出了在无工具主实验中,11 个具有可用推理轨迹的模型所产生的 4,982 个错误回答各自的错误类型(附录 A.1、图 6 和图 7)。各列为 model (与 settings/models.json), question_id 和 error_type:

  • perceptual 中的定义相同)(717 个回答):回答错误解读了页面。
  • logical (3,129 个):数值读取正确,但组合方式错误。
  • hallucination (240 个):回答使用了页面上不存在的数值。
  • other (896 个):其余失败,包括未给出答案便结束的回答。

这些回答涉及 932 道题中的 838 道。对于 11 个模型中的每一个,行数均等于其在表 2 中的错误答案数量。

构建过程

construction/ 介绍了页面和问题的构建方式(论文图 2 和图 3),并提供了一个完整示例:DG004 的事实与文本、两个相互独立且复现数据参考答案的求解器,以及另外三个视觉示例的实现。参见 construction/README.md.

引用

@article{li2026docgallery,
  title   = {DocGallery: Diagnosing Multi-Hop Visual Reasoning in Rich Documents},
  author  = {Li, Zhiheng and Li, Zongyi and Zhang, Hengrui and Su, Ziyu and Lan, Jun and Zhang, Beibei and Li, Yansi and Cao, Linhan and Yu, Zhiyin and Chen, Jiaxian and Zhang, Jianing and Lin, Haobo and Yu, Hao and Liu, Kang and Zhao, Linnan and Zhu, Huijia and Wang, Weiqiang and Ma, Zongyang and Zhang, Ziqi and Yuan, Chunfeng and Li, Bing and Hu, Weiming},
  journal = {arXiv preprint},
  year    = {2026}
}

许可证

本仓库中的代码依据 MIT 许可证(LICENSE)发布。Hugging Face 上的数据依据 CC BY-NC 4.0 许可证发布。

关于

未提供描述、网站或主题。

资源

自述文件MIT 许可证动态自定义属性

星标

0 个星标

关注者

0 人正在关注

复刻

0 个复刻举报仓库

发行版

软件包

使用者

贡献者

语言