Skip to content

Commit 77731e2

Browse files
committed
feat(datasets): add HLE datasets(code & doc & UT)
1 parent 8d39ceb commit 77731e2

8 files changed

Lines changed: 890 additions & 2 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# HLE (Humanity's Last Exam)
2+
中文 | [English](README_en.md)
3+
4+
## 数据集简介
5+
6+
HLE(Humanity's Last Exam)是 Center for AI Safety 发布的前沿多模态基准测试数据集,旨在成为最后一个广泛覆盖学科领域的闭卷学术基准测试。该数据集包含 2,500 道高质量题目,涵盖数学、人文科学、自然科学等多个学科领域。题目由领域专家精心设计,确保了题目的专业性和挑战性。HLE 支持纯文本和图像输入,并通过 LLM Judge 评估协议进行自动评分,同时提供置信度校准指标,适合全面评估模型在多学科知识和多模态理解方面的能力。
7+
8+
> 🔗 数据集主页链接: [https://huggingface.co/datasets/cais/hle](https://huggingface.co/datasets/cais/hle)
9+
>
10+
> 🔗 官方 GitHub 仓库: [https://github.com/centerforaisafety/hle](https://github.com/centerforaisafety/hle)
11+
12+
13+
## 数据集部署
14+
15+
- HLE 数据集为 Parquet 格式,建议部署在 `{tool_root_path}/ais_bench/datasets/hle/data/` 目录下。
16+
- 您可以按照以下方式从 ModelScope 或 HuggingFace 下载数据集:
17+
18+
```bash
19+
# 创建目标目录
20+
mkdir -p {tool_root_path}/ais_bench/datasets/hle/
21+
22+
# 使用 modelscope 下载 (需要安装 modelscope)
23+
modelscope download --dataset cais/hle --local_dir {tool_root_path}/ais_bench/datasets/hle/
24+
25+
# 使用 huggingface-cli 下载 (需要安装 transformers 并登录)
26+
huggingface-cli download cais/hle --repo-type dataset --local-dir {tool_root_path}/ais_bench/datasets/hle/
27+
```
28+
29+
-`{tool_root_path}/ais_bench/datasets/hle/data/` 目录下执行 `ls -la` 检查目录结构。如果目录结构如下所示,则数据集部署成功:
30+
```
31+
{tool_root_path}/ais_bench/datasets/hle/data/
32+
└── test-00000-of-00001.parquet
33+
```
34+
35+
36+
## 可用数据集任务
37+
38+
| 任务名称 | 简介 | 评估指标 | Few-Shot | Prompt 格式 | 对应源码配置文件路径 |
39+
| --- | --- | --- | --- | --- | --- |
40+
| hle | HLE 数据集 | 准确率 (accuracy)、置信度校准误差 (calibration_error) | 0-shot | 对话格式 | hle_llmjudge.py |
41+
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# HLE (Humanity's Last Exam)
2+
[中文](README.md) | English
3+
4+
## Dataset Introduction
5+
6+
HLE (Humanity's Last Exam) is a frontier multimodal benchmark dataset released by the Center for AI Safety, designed to be the last widely covering closed-book academic benchmark across multiple subject domains. The dataset contains 2,500 high-quality questions covering multiple subject areas including mathematics, humanities, and natural sciences. The questions are carefully designed by domain experts, ensuring professional quality and challenging difficulty. HLE supports both pure text and image inputs, and uses the LLM Judge evaluation protocol for automatic scoring while providing confidence calibration metrics. It is suitable for comprehensive evaluation of models' capabilities in multidisciplinary knowledge and multimodal understanding.
7+
8+
> 🔗 Dataset Homepage Link: [https://huggingface.co/datasets/cais/hle](https://huggingface.co/datasets/cais/hle)
9+
>
10+
> 🔗 Official GitHub Repository: [https://github.com/centerforaisafety/hle](https://github.com/centerforaisafety/hle)
11+
12+
13+
## Dataset Deployment
14+
15+
- The HLE dataset is in Parquet format and is recommended to be deployed in the `{tool_root_path}/ais_bench/datasets/hle/data/` directory.
16+
- You can download the dataset from ModelScope or HuggingFace as follows:
17+
```bash
18+
# Create target directory
19+
mkdir -p {tool_root_path}/ais_bench/datasets/hle/
20+
21+
# Download using modelscope(requires installing modelscope)
22+
modelscope download --dataset cais/hle --local_dir {tool_root_path}/ais_bench/datasets/hle/
23+
24+
# Download using huggingface-cli (requires installing transformers and logging in)
25+
huggingface-cli download cais/hle --repo-type dataset --local-dir {tool_root_path}/ais_bench/datasets/hle/
26+
27+
```
28+
29+
- Execute `ls -la` in the `{tool_root_path}/ais_bench/datasets/hle/data/` directory to check the directory structure. If the directory structure is as shown below, the dataset has been deployed successfully:
30+
```
31+
{tool_root_path}/ais_bench/datasets/hle/data/
32+
└── test-00000-of-00001.parquet
33+
```
34+
35+
36+
## Available Dataset Tasks
37+
38+
| Task Name | Introduction | Evaluation Metric | Few-Shot | Prompt Format | Corresponding Source Code Configuration File Path |
39+
| --- | --- | --- | --- | --- | --- |
40+
| hle | HLE dataset | Accuracy, Calibration Error | 0-shot | Chat format | hle_llmjudge.py |
41+
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
from ais_bench.benchmark.datasets import HLEDataset, HLEJGDataset
2+
from ais_bench.benchmark.datasets.hle import HLEJudgeEvaluator
3+
from ais_bench.benchmark.models import VLLMCustomAPIChat
4+
from ais_bench.benchmark.openicl.icl_inferencer import GenInferencer
5+
from ais_bench.benchmark.openicl.icl_prompt_template import (MMPromptTemplate,
6+
PromptTemplate)
7+
from ais_bench.benchmark.openicl.icl_retriever import ZeroRetriever
8+
from ais_bench.benchmark.utils.postprocess.model_postprocessors import \
9+
extract_non_reasoning_content
10+
11+
# Model inference prompt template - aligned with official HLE format
12+
HLE_INFER_PROMPT = "Your response should be in the following format:\nExplanation: {your explanation for your answer choice}\nAnswer: {your chosen answer}\nConfidence: {your confidence score between 0% and 100% for your answer}"
13+
14+
15+
hle_reader_cfg = dict(input_columns=["question", "image"], output_column="answer")
16+
17+
18+
hle_infer_cfg = dict(
19+
prompt_template=dict(
20+
type=MMPromptTemplate,
21+
template=dict(
22+
begin=[
23+
dict(
24+
role="SYSTEM",
25+
prompt=HLE_INFER_PROMPT,
26+
)
27+
],
28+
round=[
29+
dict(
30+
role="HUMAN",
31+
prompt_mm={
32+
"text": {"type": "text", "text": "{question}"},
33+
"image": {"type": "image_url", "image_url": {"url": "{image}"}},
34+
},
35+
)
36+
],
37+
),
38+
),
39+
retriever=dict(type=ZeroRetriever),
40+
inferencer=dict(type=GenInferencer),
41+
)
42+
43+
44+
# Judge model prompt template. Instructs the judge to extract answer and evaluate correctness - aligned with official HLE format
45+
JUDGE_PROMPT = """
46+
Judge whether the following [response] to [question] is correct or not based on the precise and unambiguous [correct_answer] below.
47+
48+
[question]: {question}
49+
50+
[response]: {model_answer}
51+
52+
Your judgement must be in the format and criteria specified below:
53+
54+
extracted_final_answer: The final exact answer extracted from the [response]. Put the extracted answer as 'None' if there is no exact, final answer to extract from the response.
55+
56+
[correct_answer]: {answer}
57+
58+
reasoning: Explain why the extracted_final_answer is correct or incorrect based on [correct_answer], focusing only on if there are meaningful differences between [correct_answer] and the extracted_final_answer. Do not comment on any background to the problem, do not attempt to solve the problem, do not argue for any answer different than [correct_answer], focus only on whether the answers match.
59+
60+
correct: Answer 'yes' if extracted_final_answer matches the [correct_answer] given above, or is within a small margin of error for numerical problems. Answer 'no' otherwise, i.e. if there if there is any inconsistency, ambiguity, non-equivalency, or if the extracted answer is incorrect.
61+
62+
confidence: The extracted confidence score between 0|\%| and 100|\%| from [response]. Put 100 if there is no confidence score available.
63+
""".strip()
64+
65+
66+
# JSON schema for structured judge model output
67+
RESPONSE_FORMAT_SCHEMA = {
68+
"type": "json_schema",
69+
"json_schema": {
70+
"schema": {
71+
"properties": {
72+
"extracted_final_answer": {
73+
"title": "Extracted Final Answer",
74+
"type": "string",
75+
},
76+
"reasoning": {"title": "Reasoning", "type": "string"},
77+
"correct": {
78+
"title": "Correct",
79+
"enum": ["yes", "no"],
80+
"type": "string",
81+
},
82+
"confidence": {"title": "Confidence", "type": "integer"},
83+
"strict": {"const": True, "type": "boolean"},
84+
},
85+
"required": [
86+
"extracted_final_answer",
87+
"reasoning",
88+
"correct",
89+
"confidence",
90+
"strict",
91+
],
92+
"type": "object",
93+
"additionalProperties": False,
94+
},
95+
"name": "ExtractedAnswer",
96+
"strict": True,
97+
},
98+
}
99+
100+
101+
hle_judge_infer_cfg = dict(
102+
judge_reader_cfg=dict(
103+
input_columns=["question", "answer", "model_answer"],
104+
output_column="model_pred_uuid",
105+
),
106+
judge_model=dict(
107+
attr="service",
108+
type=VLLMCustomAPIChat,
109+
abbr="judge",
110+
path="",
111+
model="",
112+
stream=False,
113+
request_rate=0,
114+
use_timestamp=False,
115+
retry=2,
116+
api_key="",
117+
host_ip="localhost",
118+
host_port=8080,
119+
url="",
120+
max_out_len=8192,
121+
batch_size=100,
122+
trust_remote_code=False,
123+
generation_kwargs=dict(
124+
temperature=0.01,
125+
seed=0,
126+
response_format=RESPONSE_FORMAT_SCHEMA,
127+
chat_template_kwargs=dict(
128+
enable_thinking=False,
129+
),
130+
),
131+
),
132+
judge_dataset_type=HLEJGDataset,
133+
prompt_template=dict(
134+
type=PromptTemplate,
135+
template=dict(
136+
round=[
137+
dict(role="HUMAN", prompt=JUDGE_PROMPT),
138+
],
139+
),
140+
),
141+
retriever=dict(type=ZeroRetriever),
142+
inferencer=dict(type=GenInferencer),
143+
)
144+
145+
146+
hle_eval_cfg = dict(
147+
evaluator=dict(type=HLEJudgeEvaluator),
148+
)
149+
150+
151+
hle_datasets = [
152+
dict(
153+
abbr="hle",
154+
type=HLEDataset,
155+
path="ais_bench/datasets/hle/data/test-00000-of-00001.parquet",
156+
reader_cfg=hle_reader_cfg,
157+
infer_cfg=hle_infer_cfg,
158+
judge_infer_cfg=hle_judge_infer_cfg,
159+
eval_cfg=hle_eval_cfg,
160+
)
161+
]

ais_bench/benchmark/datasets/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,4 @@
5959
from ais_bench.benchmark.datasets.mooncake_trace import * # noqa: F401, F403
6060
from ais_bench.benchmark.datasets.swebench import * # noqa: F401, F403
6161
from ais_bench.benchmark.datasets.refcoco import * # noqa: F401, F403
62+
from ais_bench.benchmark.datasets.hle import *

0 commit comments

Comments
 (0)