Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 37 additions & 38 deletions src/benchmarks/vgi-bench/benchmark.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,19 @@ const VGI_RECORD: Readonly<Record<string, unknown>> = {
};

describe("vgiBenchRecordToSample", () => {
it("builds the pinned multiple-choice prompt with lowercase letters", () => {
it("maps a record to a sample with uppercase prompt, video content part, target, and metadata", () => {
const sample = vgiBenchRecordToSample(VGI_RECORD, 0);
expect(sample.input).toMatchInlineSnapshot(`
expect(sample).toMatchInlineSnapshot(`
{
"contentParts": [
{
"type": "video_url",
"videoUrl": {
"url": "https://cdn.seldon.global/videos/clip_007.mp4",
},
},
{
"text":
"Watch the video and answer the multiple choice question about it. The last line of your response should be of the following format: 'Answer: $LETTER' (without quotes) where LETTER is one of ABCD.

Question: What color is the car in the first scene?
Expand All @@ -40,38 +50,32 @@ describe("vgiBenchRecordToSample", () => {
B) blue
C) green
D) yellow"
`);
});

it("places content parts: video_url first, then text", () => {
const sample = vgiBenchRecordToSample(VGI_RECORD, 0);
expect(sample.contentParts).toBeDefined();
expect(sample.contentParts).toHaveLength(2);
expect(sample.contentParts![0]).toEqual({
type: "video_url",
videoUrl: { url: "https://cdn.seldon.global/videos/clip_007.mp4" },
});
expect(sample.contentParts![1]!.type).toBe("text");
});

it("derives the target letter from correct_answer index (uppercase)", () => {
const sample = vgiBenchRecordToSample(VGI_RECORD, 0);
expect(sample.target.text).toBe("B");
});
,
"type": "text",
},
],
"id": "vgi_bench-42",
"input":
"Watch the video and answer the multiple choice question about it. The last line of your response should be of the following format: 'Answer: $LETTER' (without quotes) where LETTER is one of ABCD.

it("uses question_id for a stable sample id", () => {
const sample = vgiBenchRecordToSample(VGI_RECORD, 0);
expect(sample.id).toBe("vgi_bench-42");
});
Question: What color is the car in the first scene?

it("records family and question_type metadata but never the canary", () => {
const sample = vgiBenchRecordToSample(VGI_RECORD, 0);
expect(sample.metadata?.["question_type"]).toBe(
"contrastive-hard-negative/transcript_visual"
);
expect(sample.metadata?.["family"]).toBe("contrastive-hard-negative");
expect(sample.metadata?.["video_id"]).toBe("clip_007");
expect(sample.metadata?.["question_id"]).toBe(42);
A) red
B) blue
C) green
D) yellow"
,
"metadata": {
"family": "contrastive-hard-negative",
"question_id": 42,
"question_type": "contrastive-hard-negative/transcript_visual",
"video_id": "clip_007",
},
"target": {
"text": "B",
},
}
`);
expect(JSON.stringify(sample.metadata)).not.toContain("canary");
expect(JSON.stringify(sample.input)).not.toContain("canary");
});
Expand Down Expand Up @@ -135,11 +139,6 @@ describe("downscaledVideoUrl", () => {
"https://cdn.seldon.global/v/clip_007_proxy_v2"
);
});
it("does not splice into dots in the hostname for extension-less paths", () => {
expect(downscaledVideoUrl("https://cdn.seldon.global/v/clip_007")).toBe(
"https://cdn.seldon.global/v/clip_007_proxy_v2"
);
});
it("operates only on the final path segment, not earlier directories", () => {
expect(
downscaledVideoUrl("https://cdn.seldon.global/v1.2/clip_007.mp4")
Expand All @@ -157,7 +156,7 @@ describe("buildVgiBenchPrompt", () => {

A) yes
B) no"
`);
`);
});
});

Expand Down
8 changes: 4 additions & 4 deletions src/benchmarks/vgi-bench/benchmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { defineChatBenchmark } from "../define-chat-benchmark";
import { mcqScorer } from "../scorers/mcq/scorer";
import type { Benchmark } from "../types";

export const VGI_BENCH_DATASET_PATH = "Seldon-Technologies/VGIBench";
const VGI_BENCH_DATASET_PATH = "Seldon-Technologies/VGIBench";

const VGI_BENCH_CONFIG = "default";
const VGI_BENCH_SPLIT = "train";
Expand All @@ -32,7 +32,7 @@ const PROXY_SUFFIX = "_proxy_v2";

const LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

export const VGI_BENCH_TEMPERATURE = 0;
const VGI_BENCH_TEMPERATURE = 0;

export function buildVgiBenchPrompt(
question: string,
Expand Down Expand Up @@ -147,7 +147,7 @@ interface VgiBenchDatasetOpts extends VgiBenchRecordToSampleOptions {
readonly revision?: string;
}

export function makeVgiBenchDatasetLayer(
function makeVgiBenchDatasetLayer(
opts?: VgiBenchDatasetOpts
): Layer<DatasetTag> {
const config: HfDatasetConfig = {
Expand All @@ -166,7 +166,7 @@ export function makeVgiBenchDatasetLayer(
return makeHfDatasetLayer(config);
}

export function vgiBenchSolver(
function vgiBenchSolver(
model: ModelService,
opts?: {
readonly endpointId?: string;
Expand Down
Loading