---
title: vbench
---

<div class="python-reference">
<a id="fastvideo.eval.datasets.vbench-classes"></a>
<a id="fastvideo.eval.datasets.vbench-functions"></a>
<a id="fastvideo.eval.datasets.vbench"></a>
<p>VBench prompt corpus.</p>
<p>Single source of truth: upstream's <code>VBench_full_info.json</code> (946 entries,
each with <code>prompt_en</code>, a <code>dimension</code> list, optional <code>auxiliary_info</code>
keyed by dimension).</p>
<h2 id="fastvideo.eval.datasets.vbench.PromptDataset"><code>fastvideo.eval.datasets.vbench.PromptDataset</code></h2>
<pre class="doc-signature"><code>PromptDataset()</code></pre>
<p>Iterable corpus of sample dicts. Subclasses populate <code>self._rows</code>.</p>

<h3 id="fastvideo.eval.datasets.vbench.PromptDataset.by_dimension"><code>fastvideo.eval.datasets.vbench.PromptDataset.by_dimension</code></h3>
<pre class="doc-signature"><code>by_dimension() -&gt; dict&#91;str, list&#91;dict&#93;&#93;</code></pre>
<p>Group samples by dimension. A multi-dim sample appears under each.</p>
<h2 id="fastvideo.eval.datasets.vbench.register_dataset"><code>fastvideo.eval.datasets.vbench.register_dataset</code></h2>
<pre class="doc-signature"><code>register_dataset(name: str)</code></pre>
<p>Decorator to register a prompt-dataset class.</p>
<p>Usage::</p>
<pre><code>@register_dataset("vbench")
class VBenchPromptDataset(BasePromptDataset):
    ...
</code></pre>
<h2 id="fastvideo.eval.datasets.vbench.VBenchPromptDataset"><code>fastvideo.eval.datasets.vbench.VBenchPromptDataset</code></h2>
<pre class="doc-signature"><code>VBenchPromptDataset(dimensions: list&#91;str&#93; | str = &#x27;all&#x27;, full_info_path: str | Path | None = None)</code></pre>
<p>VBench prompts filtered by evaluation dimension.</p>
<h3>Parameters</h3>
<dl>
<dt><code>dimensions: list[str] | str</code></dt><dd><p>List of dimension names, or <code>"all"</code>. Unknown
dimensions raise <code>ValueError</code>.</p></dd>
<dt><code>full_info_path: str | Path | None</code></dt><dd><p>Optional override for <code>VBench_full_info.json</code>;
defaults to autodetection.</p></dd>
</dl>
<p>A prompt that belongs to several requested dimensions is yielded once;
its <code>dimensions</code> list carries all matches so the scorer can route.</p>

<details><summary>Source</summary><pre><code>@register_dataset(&quot;vbench&quot;)
class VBenchPromptDataset(PromptDataset):
    &quot;&quot;&quot;VBench prompts filtered by evaluation dimension.

    Args:
        dimensions: List of dimension names, or ``&quot;all&quot;``. Unknown
            dimensions raise ``ValueError``.
        full_info_path: Optional override for ``VBench_full_info.json``;
            defaults to autodetection.

    A prompt that belongs to several requested dimensions is yielded once;
    its ``dimensions`` list carries all matches so the scorer can route.
    &quot;&quot;&quot;

    description = (&quot;VBench (Vchitect) prompt corpus, 946 prompts across 16 &quot;
                   &quot;evaluation dimensions.&quot;)
    supports_dimensions = True

    def __init__(
        self,
        dimensions: list&#91;str&#93; | str = &quot;all&quot;,
        full_info_path: str | Path | None = None,
    ) -&gt; None:
        super().__init__()
        path = Path(full_info_path) if full_info_path else _locate_full_info()
        with path.open() as f:
            entries = json.load(f)

        all_dims = sorted(&#123;d for e in entries for d in e&#91;&quot;dimension&quot;&#93;&#125;)
        if dimensions == &quot;all&quot;:
            self.dimensions: list&#91;str&#93; = all_dims
        else:
            unknown = set(dimensions) - set(all_dims)
            if unknown:
                raise ValueError(f&quot;Unknown VBench dimensions: &#123;sorted(unknown)&#125;. &quot;
                                 f&quot;Available: &#123;all_dims&#125;&quot;)
            self.dimensions = list(dimensions)

        wanted = set(self.dimensions)
        for entry in entries:
            relevant = &#91;d for d in entry&#91;&quot;dimension&quot;&#93; if d in wanted&#93;
            if not relevant:
                continue
            n = (TEMPORAL_FLICKERING_SAMPLES if &quot;temporal_flickering&quot; in relevant else DEFAULT_SAMPLES)

            # Strip the outer &#123;dim_name: ...&#125; wrapper from upstream&#x27;s aux
            # schema so every metric reads its inputs from a flat dict.
            #
            # This unwraps exactly one level — the dimension key. Whatever
            # shape lives inside is the metric&#x27;s contract:
            #
            #   color:                &#123;&quot;color&quot;: &#123;&quot;color&quot;: &quot;red&quot;&#125;&#125;
            #     → flat: &#123;&quot;color&quot;: &quot;red&quot;&#125;                  (scalar)
            #
            #   object_class:         &#123;&quot;object_class&quot;: &#123;&quot;object&quot;: &quot;person&quot;&#125;&#125;
            #     → flat: &#123;&quot;object&quot;: &quot;person&quot;&#125;              (scalar)
            #
            #   multiple_objects:     &#123;&quot;multiple_objects&quot;: &#123;&quot;object&quot;: &quot;a and b&quot;&#125;&#125;
            #     → flat: &#123;&quot;object&quot;: &quot;a and b&quot;&#125;             (scalar)
            #
            #   spatial_relationship: &#123;&quot;spatial_relationship&quot;:
            #                            &#123;&quot;spatial_relationship&quot;:
            #                                &#123;&quot;object_a&quot;: ..., &quot;object_b&quot;: ...,
            #                                 &quot;relationship&quot;: ...&#125;&#125;&#125;
            #     → flat: &#123;&quot;spatial_relationship&quot;: &#123;object_a,object_b,relationship&#125;&#125;
            #
            # Note the spatial_relationship case keeps a nested inner dict
            # by design — upstream double-wraps it, the SpatialRelationship
            # metric reads ``aux&#91;&quot;spatial_relationship&quot;&#93;`` expecting that
            # inner dict. Don&#x27;t &quot;simplify&quot; the wrapping away.
            raw_aux = entry.get(&quot;auxiliary_info&quot;) or &#123;&#125;
            flat_aux: dict = &#123;&#125;
            for v in raw_aux.values():
                if isinstance(v, dict):
                    flat_aux.update(v)

            self._rows.append(&#123;
                &quot;prompt&quot;: entry&#91;&quot;prompt_en&quot;&#93;,
                &quot;n_samples&quot;: n,
                &quot;dimensions&quot;: relevant,
                &quot;auxiliary_info&quot;: flat_aux,
            &#125;)
        self.full_info_path = path</code></pre></details>
</div>
