SEED-Bench:大规模多模态生成评测基准

FreeGuideOnline 最新 2026-06-22

json { "question_id": 1, "image": "path/to/image.jpg", "question": "How many cats are in the image?", "choice_a": "1", "choice_b": "2", "choice_c": "3", "choice_d": "4", "answer": "C", "data_type": "instance_counting", "category": "Spatial Understanding" }


模型需要接收 **图像 + 问题 + 所有选项** 作为输入,然后输出所选的选项 ID(如 `"C"` 或 `"c"`)。评测脚本会自动提取答案并与标准答案比对。

### 5. 快速上手:安装与准备

SEED‑Bench 的全部数据与评测工具已开源,你可以通过以下步骤在本地搭建评测环境。

#### 5.1 下载数据集与资源

```bash
# 克隆官方仓库
git clone https://github.com/AILab-CVC/SEED-Bench.git
cd SEED-Bench

# 下载图片(你需要同意协议后从官方链接获取)
# 官方提供百度网盘 / Google Drive 链接,假设已解压至 ./data/seed_bench_image

数据集包含一个 SEED-Bench.json 文件(即全部问题)以及一个图像文件夹。

5.2 安装评测依赖

pip install -r requirements.txt

核心依赖:torch, transformers, Pillow, tqdm 等。

6. 评估你的多模态模型

评测流程极为标准化,只需让你的模型在每一道题上输出一个选项字母,然后调用评测脚本。

6.1 生成模型答案文件

你需要编写一个推理脚本,遍历所有题目,生成一个答案文件。答案文件为 JSON 列表,格式如下:

[
  {
    "question_id": 1,
    "prediction": "C"
  },
  {
    "question_id": 2,
    "prediction": "A"
  }
  ...
]

为了帮助初学者快速实现,官方提供了一个示例模板 eval/eval.py,你只需填入模型的推理逻辑。例如,使用一个假想的 MLLM:

from transformers import AutoModelForVision2Seq, AutoProcessor
from PIL import Image

model = AutoModelForVision2Seq.from_pretrained("your-mllm")
processor = AutoProcessor.from_pretrained("your-mllm")

def get_model_answer(image_path, question, choices):
    # 构建提示
    option_text = "\n".join([f"({k}) {v}" for k,v in choices.items()])
    prompt = f"Question: {question}\nOptions: {option_text}\nAnswer with the option's letter from the given choices directly."
    
    image = Image.open(image_path).convert("RGB")
    inputs = processor(text=prompt, images=image, return_tensors="pt")
    outputs = model.generate(**inputs)
    response = processor.decode(outputs[0], skip_special_tokens=True).strip()
    # 提取选项字母
    return response[0].upper()

6.2 运行评测

将生成的答案文件保存为 results/submit.json,然后执行:

python eval/eval.py --annotation-file SEED-Bench.json --result-file results/submit.json