TANDREWYANG's picture
Add Part 2: ActionFollowing data (videos, eval_set, checkpoints, train_data)
cb82310 verified
|
Raw History Blame Contribute Delete
13.7 kB
# ActionFollowing — VLM Judge 评测说明
## 任务概述
训练一个 VLM 裁判模型,对机器人 world model 生成的预测视频打分。
**World model 的输入输出:**
- 输入:任务指令(如 "pick up the red cup")+ 初始场景图像
- 输出:预测视频(机器人应如何执行该任务)
**VLM 裁判的任务:** 对比预测视频与真实执行视频,输出 3 个二值指标。
**最终评估指标:** 预测 OS 分数(整数)与参考 OS 分数(连续值)之间的 Spearman ρ + Pairwise Accuracy。
---
## OS 分数公式
```
OS = TCR × 40 + OPS × 35 + MQ × 25
```
整数 OS 取值:0, 25, 35, 40, 60, 65, 75, 100
---
## 三个二值指标
| 指标 | 含义 | =1(正) | =0(负) |
|---|---|---|---|
| **TCR** | Task Completion Result | 机器人清晰完成了指令描述的任务 | 失败/提前停止/动作错误/结果模糊 |
| **OPS** | Object-Physical Score | 物体交互物理合理 | 物体穿模/瞬移/消失/渲染异常 |
| **MQ** | Motion Quality | 机器人运动流畅、时序连贯 | 抖动/冻帧/运动不自然 |
---
## 模型输入格式
每次推理传入一个 **SBS 合并视频**(side-by-side):预测视频在左,真实视频在右,高度统一缩放到 480px。
```bash
ffmpeg -i pred.mp4 -i gt.mp4 \
-filter_complex "[0:v]scale=-2:480,setsar=1[l];[1:v]scale=-2:480,setsar=1[r];[l][r]hstack=inputs=2" \
-r 10 -c:v libx264 merged_sbs.mp4
```
- 分辨率:~1280×480(左右各约 640×480)
- 帧率:10 fps,训练/推理时采样 8 帧(`video_maxlen=8`)
- `video_max_pixels=200704`(256×28×28)
---
## Prompt 模板
### merged_sbs(无 CoT)
```
<video>
You are an expert evaluator assessing whether a robot world model correctly predicts action-following behavior.
A world model takes a task instruction and an initial scene, then predicts how the robot should execute that action.
Your job is to determine: did the world model predict the correct robot behavior for the given instruction?
VIDEO LAYOUT: The video shows TWO views side by side:
• LEFT = PREDICTED video (world model output — evaluate this)
• RIGHT = GROUND TRUTH video (real robot execution — reference only)
Task instruction: "{instruction}"
Evaluate the predicted video (LEFT side) on 3 independent binary metrics.
Use the ground truth (RIGHT side) as reference for what correct action execution looks like —
your scores reflect ONLY the quality of the LEFT (predicted) video.
1. TCR (Task Completion Result): Did the robot in the predicted video successfully complete the instructed task?
• 1 = Yes — the robot clearly performs the full action described and reaches a successful outcome
• 0 = No — the robot fails, stops early, performs the wrong action, or the outcome is ambiguous
2. OPS (Object-Physical Score): Does the predicted video show physically plausible and correct object interactions?
• 1 = Yes — object movements, grasps, contacts, and reactions are realistic and consistent with real-world physics
• 0 = No — objects move unrealistically, clip through surfaces, disappear/appear unexpectedly, or major artifacts distort interactions
3. MQ (Motion Quality): Is the robot's motion in the predicted video smooth, coherent, and realistic?
• 1 = Yes — arm movements are fluid and purposeful; video has consistent temporal coherence without severe blur or jitter
• 0 = No — motion is jerky, frozen, nonsensical, or video quality severely degrades the legibility of the action
Respond ONLY with valid JSON (no markdown, no extra text):
{
"TCR": <0 or 1>,
"OPS": <0 or 1>,
"MQ": <0 or 1>,
"reasoning": "<one sentence>"
}
```
### merged_v2_sbs(4步 CoT)
在 merged_sbs 的基础上,要求模型先逐步分析再输出 JSON:
```
<video>
You are an expert evaluator assessing robot world model quality for action-following.
CONTEXT: A world model receives a task instruction and generates a video predicting how a robot
should execute the task. Your job: did the world model predict the correct action and execute it well?
VIDEO LAYOUT: The video shows TWO views side by side:
• LEFT = PREDICTED video (world model output — evaluate this)
• RIGHT = GROUND TRUTH video (real robot execution — reference only)
TASK INSTRUCTION: "{instruction}"
STEP-BY-STEP ANALYSIS:
Step 1 — What does the task require? Identify the specific action and the target object.
Step 2 — Inventory the scene: what objects are present? Watch the LEFT video for any object that
deforms, disappears, or changes shape — these are strong signals for OPS=0.
Step 3 — What does the predicted video (LEFT) actually show? Does the robot attempt the correct
action on the correct object, and does it reach the expected end state?
Step 4 — Score each metric INDEPENDENTLY for the predicted video (LEFT side) only:
1. TCR: Did the robot complete the task?
• 1 = correct action on correct object, successful end state
• 0 = wrong action / wrong object / stops early / outcome unclear
2. OPS: Are object interactions physically plausible?
• 1 = objects respond correctly; grasps stable; no major artifacts
• 0 = objects teleport / clip / disappear / rendering fails
3. MQ: Is the robot's motion smooth and coherent?
• 1 = arm moves fluidly; no freezing or severe temporal discontinuity
• 0 = arm teleports / video freezes / severe jitter / physically impossible motion
First write your analysis (Steps 1–4), then output the JSON scores.
Respond with your analysis followed by valid JSON (no markdown):
{
"TCR": <0 or 1>,
"OPS": <0 or 1>,
"MQ": <0 or 1>,
"reasoning": "<one sentence overall summary>"
}
```
---
## 候选裁判模型
### Model A:Qwen3-VL-8B-Instruct
- **基础模型:** `/mnt/public/models/qwen_vl/Qwen3-VL-8B-Instruct`
- **微调方式:** LoRA(rank=16, alpha=32, target=all, dropout=0.1),5 epochs,lr=5e-5,cosine schedule
- **模板:** `qwen3_vl_nothink`(抑制 `<think>` 推理 token)
- **GPU:** 单张 A100-80G
- **框架:** LLaMA-Factory
### Model B:InternVL3-78B
- **基础模型:** `/mnt/public/models/InternVL3-78B`
- **架构:** InternViT-6B-448px-V2_5 + Qwen2.5-72B LLM
- **微调方式:** LoRA(rank=16, alpha=32, target=all, dropout=0.1),5 epochs,lr=5e-5,cosine schedule
- **模板:** `intern_vl`
- **GPU:** 4× A100-80G,DeepSpeed ZeRO-3(bfloat16 约需 156GB)
- **框架:** LLaMA-Factory + DeepSpeed ZeRO-3
---
## train_data 文件夹结构
```
train_data/
├── README.md # 本文件
│
├── train_merged_sbs.json # 训练集,merged_sbs prompt(109条,含过采样��
├── train_merged_v2_sbs.json # 训练集,merged_v2_sbs prompt(CoT版本,同样109条)
├── val_merged_sbs.json # 验证集,merged_sbs prompt(42条)
├── val_merged_v2_sbs.json # 验证集,merged_v2_sbs prompt(42条)
├── test_labels.json # 测试集参考标签(50条,GPT-4o标注)
│
└── videos/
├── train/ # 83个 SBS 合并视频(merged_sbs,训练原始样本)
│ └── human_XXX_merged.mp4
├── val/ # 42个 SBS 合并视频
│ └── human_XXX_merged.mp4
└── test/ # 50个测试 episode
└── episode_XXXX/
├── pred.mp4 # 预测视频(SBS左侧来源)
└── gt.mp4 # 真实执行视频(SBS右侧来源)
```
> **注意:** train/val 的 JSON 文件中 `videos` 字段为绝对路径,使用前需根据本地路径修改,或在 LLaMA-Factory 中配置 `dataset_dir`。
---
## JSON 文件格式
### train_merged_sbs.json / val_merged_sbs.json
LLaMA-Factory ShareGPT 格式,每条样本:
```json
{
"messages": [
{
"role": "user",
"content": "<video>\n...Task instruction: \"pick apple b\"...\n{\"TCR\": <0 or 1>, ...}"
},
{
"role": "assistant",
"content": "{\"TCR\": 0, \"OPS\": 0, \"MQ\": 0, \"reasoning\": \"\"}"
}
],
"videos": [
"/mnt/users/zirui/mizirui_benchmark/World_Fufu/ActionFollowing/dataset_human_binary/merged/human_048_merged.mp4"
]
}
```
- `messages[0].content`:完整 prompt,instruction 已内嵌
- `messages[1].content`:标签(TCR/OPS/MQ 二值)
- `videos`:SBS 合并视频绝对路径(LLaMA-Factory 直接读取)
### test_labels.json
测试集参考标签(GPT-4o 标注),每条样本:
```json
{
"episode": 5,
"scores": {
"TCR": 1.0,
"OPS": "high",
"MQ": "medium"
},
"os": 87.5,
"instruction": "A GR1 humanoid robot stands in front of...",
"reasoning": "The robot's arm motion is unnatural and jerky..."
}
```
**二值化规则(与训练标签对齐):**
| 指标 | =1 | =0 |
|---|---|---|
| TCR | `scores.TCR == 1` | 否则 |
| OPS | `scores.OPS == "high"` | `"medium"` 或 `"low"` |
| MQ | `scores.MQ == "high"` | `"medium"` 或 `"low"` |
---
## 训练集构建逻辑
**数据来源:** 人工标注(`raw_annotations.json`),共 238 条原始标注
**MQ 阈值修正:** 训练集 MQ=1 的阈值与测试集对齐
| | 旧版 | 当前(mq_fixed) | 测试集 |
|---|---|---|---|
| MQ=1 门槛 | 及格(3)+良好(4)+优秀(5) | 良好(4)+优秀(5) | high(良好/优秀)|
| 正样本率 | ~54% | ~30% | ~28% |
旧版把 63 条"及格"标为 MQ=1,但测试集标为 MQ=0,导致模型过度预测 MQ=1,OS 方差坍塌,Spearman ρ 崩溃。
**样本过滤:**
- 丢弃 MQ=及格(3) 的样本(与测试集标准不一致)
- 丢弃已用于测试集的 50 个 episode
**数据集划分:**
| 阶段 | 样本数 | 说明 |
|---|---|---|
| 过滤后池 | 125 | 丢弃 63 条及格 + 50 条测试 episode |
| 验证集 | 42 | 按 OS 分层采样 |
| 训练集(原始)| 83 | 剩余样本 |
| **训练集(最终)**| **109** | 正样本过采样后 |
**正样本过采样:** OS≥75(即 TCR=1 且 OPS=1)的样本重复采样,直到占训练集的 40%。
**训练集 OS 分布(过采样后):**
| OS | 数量 | TCR/OPS/MQ |
|---|---|---|
| 0 | 33 | 0/0/0 |
| 25 | 10 | 0/0/1 |
| 35 | 12 | 0/1/0 |
| 40 | 1 | 1/0/0 |
| 60 | 7 | 0/1/1 |
| 65 | 2 | 1/1/0 |
| **75** | **28** | 1/1/0 或 1/0/1 |
| **100** | **16** | 1/1/1 |
| **合计** | **109** | 正样本(OS≥75)占 40.4% |
---
## 测试集
**来源:** `video_batch_final/gr1/` — 50 个 GR1 机器人执行 episode
**参考标签:** `test_labels.json`(GPT-4o 标注,已转换格式)
**测试集标签分布:**
| 指标 | 正样本率 |
|---|---|
| TCR=1 | 34/50(68%)|
| OPS=high | 37/50(74%)|
| MQ=high | 14/50(28%)|
**测试集 OS 分布(连续值):**
| OS | 数量 |
|---|---|
| 0.0 | 1 |
| 12.5 | 1 |
| 30.0 | 4 |
| 35.0 | 1 |
| 47.5 | 7 |
| 60.0 | 2 |
| 70.0 | 7 |
| 87.5 | 15 |
| 100.0 | 12 |
| **均值** | **72.5** |
> 测试集 OS 是 GPT-4o 标注的连续值(0–100),预测 OS 是整数(0/25/35/40/60/65/75/100)。Spearman ρ 基于排名比较,可正确处理两者的量纲差异。
---
## 如何使用本数据进行训练(LLaMA-Factory)
### 1. 注册数据集
在 `LLaMA-Factory/data/dataset_info.json` 中已添加以下条目:
```json
"action_human_mq_fixed_sbs_train": {
"file_name": "action_human_mq_fixed_sbs_train.json",
"formatting": "sharegpt",
"columns": {"messages": "messages", "videos": "videos"}
}
```
共 4 个条目:`_sbs_train`、`_sbs_val`、`_v2_sbs_train`、`_v2_sbs_val`。
### 2. 训练配置文件
| 运行 | 模型 | Prompt | 配置文件 |
|---|---|---|---|
| Run 10 | Qwen3-VL-8B | merged_sbs | `LLaMA-Factory/qwen3vl_mq_fixed_sbs.yaml` |
| Run 11 | Qwen3-VL-8B | merged_v2_sbs (CoT) | `LLaMA-Factory/qwen3vl_mq_fixed_v2_sbs.yaml` |
| Run 12 | InternVL3-78B | merged_sbs | `LLaMA-Factory/internvl_mq_fixed_sbs.yaml` |
| Run 13 | InternVL3-78B | merged_v2_sbs (CoT) | `LLaMA-Factory/internvl_mq_fixed_v2_sbs.yaml` |
### 3. 启动训练
```bash
# Qwen3-VL-8B,单卡
CUDA_VISIBLE_DEVICES=6 python -m llamafactory.cli train LLaMA-Factory/qwen3vl_mq_fixed_sbs.yaml
# InternVL3-78B,4卡 DeepSpeed ZeRO-3
CUDA_VISIBLE_DEVICES=0,1,2,3 python -m llamafactory.cli train LLaMA-Factory/internvl_mq_fixed_sbs.yaml
```
### 4. 重建数据集(如需修改标签/过采样比例)
```bash
python ActionFollowing/scripts/data_generation/build_dataset_mq_fixed_sbs.py
```
输出到 `LLaMA-Factory/data/`,同时生成 merged_sbs 和 merged_v2_sbs 两个版本。
---
## 如何对测试集进行评估
### Qwen3-VL-8B(base 或 LoRA)
```bash
# base model
CUDA_VISIBLE_DEVICES=0 python ActionFollowing/scripts/training/eval_basemodel_binary.py \
--prompt merged_sbs \
--output results/eval_qwen3_base_merged_sbs.json
# LoRA checkpoint
CUDA_VISIBLE_DEVICES=0 python ActionFollowing/scripts/training/eval_basemodel_binary.py \
--prompt merged_sbs \
--ckpt ActionFollowing/checkpoints/qwen3vl_mq_fixed_sbs \
--output results/eval_qwen3_run10.json
```
### InternVL3-78B(base)
```bash
# 需要 3 张 A100-80G
CUDA_VISIBLE_DEVICES=0,1,2 python ActionFollowing/scripts/training/eval_internvl_binary.py \
--prompt merged_sbs \
--output results/eval_internvl_base_merged_sbs.json
```
评估脚本自动完成:
1. 读取 `test_labels.json` 中的 instruction 和参考标签
2. 对每个 episode 用 ffmpeg 合成 SBS 视频
3. 模型推理,解析 TCR/OPS/MQ
4. 计算 per-metric Accuracy/F1、OS Spearman ρ、Pairwise Accuracy