tao-analyze-gaps-vlm-bcq
NVIDIA/skills
通过将模型响应与真实值进行对比,从VLM二元分类问题预测结果中提取假阳性与假阴性间隙,并生成结构化的JSONL文件和摘要报告,供后续根因分析使用。
...展开全部VLM 二分类差距分析
读取 VLM 预测 JSON 文件,将每个模型的响应与真实标签进行比对,并将误报(FP)/漏报(FN)的失败案例写入包含摘要报告的 JSONL 文件中。
目的
在二分类(是/否)评估任务上运行 VLM 后,需要将预测结果与真实结果进行对比,以识别失败案例。 该技能生成一份结构化的 FP(假阳性)和 FN(假阴性)样本列表,下游 RCCA 阶段(例如,cosmos 生成、根本原因分析)将利用该列表来驱动 DEFT 迭代。
用法
在 TAO Toolkit 数据服务容器内,使用 Hydra 风格的 key=value 覆盖方式调用vlm_bcq操作:
gap_analysis vlm_bcq \
predictions_json=/path/to/results.json \
results_dir=/path/to/output/gaps
当预测结果中的video_id值为相对路径时,请包含videos_dir:
gap_analysis vlm_bcq \
predictions_json=/path/to/results.json \
results_dir=/path/to/output/gaps \
videos_dir=/path/to/videos/root
运行完成后,从kpi_gaps_report.txt中提取 FP/FN 计数,并将下游阶段指向kpi_gaps.jsonl。
输入
- predictions_json:预测 JSON 文件的路径。必须是一个 JSON 数组,其中每个项包含
video_id、response和gt字段。response和gt采用词界匹配方式进行解析——字符串中任意位置出现的“yes”或“no”均会被识别。同时包含或均不包含这两个词的样本将被跳过,并伴随警告。 - videos_dir(可选):用于解析相对
video_id路径的基目录。若省略,则将video_id值视为绝对路径。
预测结果 JSON 格式:
[
{
"video_id": "/path/to/video.mp4",
"response": "Yes, there is a collision.",
"gt": "B. No",
"question": "是否存在冲突?"
}
]
输出
- kpi_gaps.jsonl:每行一个 JSON 对象,对应每个 FP/FN 案例。字段包括:
video_id(绝对路径)、error_type(FP或FN)、question、ground_truth、response。 - kpi_gaps_report.txt:包含假阳性(FP)和假阴性(FN)总计数的人类可读表格。
若未发现偏差,则不写入任何文件,并记录一条日志消息。
关键参数
| 参数 | 必填 | 描述 |
|---|---|---|
| predictions_json | 是 | 预测 JSON 文件的路径 |
| results_dir | 是 | 输出目录;若不存在则自动创建 |
| videos_dir | 否 | 用于解析相对video_id路径的基目录 |
错误模式
| 错误 | 原因 | 修复方法 |
|---|---|---|
FileNotFoundError |
predictions_json不存在 |
检查路径 |
ValueError:必须是 JSON 数组 |
预测文件不是列表 | 请将预测结果用[...]包裹起来 |
ValueError:缺少 'gt'/'response'/'video_id' |
某个预测项缺少必填字段 | 检查并修正预测 JSON |
| 样本被静默跳过 | response或gt中同时包含或均不包含 'yes'/'no' |
检查日志中的警告;检查这些样本 |
---
name: tao-analyze-gaps-vlm-bcq
description: Extract false-positive and false-negative gaps from VLM binary-classification-question predictions by comparing model responses against ground truth, producing a structured JSONL file and summary report for downstream root-cause analysis.
license: Apache-2.0
---
# VLM Binary Classification Gap Analysis
Reads a VLM predictions JSON, compares each model response against ground truth, and writes FP/FN failure cases to a JSONL file with a summary report.
## Purpose
After running a VLM on a binary yes/no evaluation task, the predictions need to be compared against ground truth to identify failure cases. This skill produces a structured list of FP (false positive) and FN (false negative) samples that downstream RCCA stages (e.g., cosmos generation, root cause analysis) consume to drive a DEFT iteration.
## Usage
Invoke the `vlm_bcq` action inside the TAO Toolkit data services container with Hydra-style key=value overrides:
```bash
gap_analysis vlm_bcq \
predictions_json=/path/to/results.json \
results_dir=/path/to/output/gaps
```
Include `videos_dir` when `video_id` values in the predictions are relative paths:
```bash
gap_analysis vlm_bcq \
predictions_json=/path/to/results.json \
results_dir=/path/to/output/gaps \
videos_dir=/path/to/videos/root
```
After the run, surface the FP/FN counts from `kpi_gaps_report.txt` and point downstream stages at `kpi_gaps.jsonl`.
## Inputs
- **predictions_json**: Path to predictions JSON file. Must be a JSON array where each item has `video_id`, `response`, and `gt` fields. `response` and `gt` are parsed with word-boundary matching — `'yes'` or `'no'` anywhere in the string is recognized. Samples where both or neither are present are skipped with a warning.
- **videos_dir** (optional): Base directory for resolving relative `video_id` paths. If omitted, `video_id` values are used as absolute paths.
**Predictions JSON format:**
```json
[
{
"video_id": "/path/to/video.mp4",
"response": "Yes, there is a collision.",
"gt": "B. No",
"question": "Is there a collision?"
}
]
```
## Outputs
- **kpi_gaps.jsonl**: One JSON object per line for each FP/FN case. Fields: `video_id` (absolute path), `error_type` (`FP` or `FN`), `question`, `ground_truth`, `response`.
- **kpi_gaps_report.txt**: Human-readable table with total FP/FN counts.
If no gaps are found, no files are written and a message is logged.
## Key Parameters
| Parameter | Required | Description |
|-----------|----------|-------------|
| predictions_json | Yes | Path to predictions JSON file |
| results_dir | Yes | Output directory; created if it does not exist |
| videos_dir | No | Base directory for resolving relative `video_id` paths |
## Error Patterns
| Error | Cause | Fix |
|-------|-------|-----|
| `FileNotFoundError` | `predictions_json` does not exist | Check the path |
| `ValueError: must be a JSON array` | Predictions file is not a list | Wrap predictions in `[...]` |
| `ValueError: missing 'gt'/'response'/'video_id'` | A prediction item is missing a required field | Inspect and fix the predictions JSON |
| Samples silently skipped | `response` or `gt` contains both or neither 'yes'/'no' | Check logs for warnings; inspect those samples |





首页
