GemmaCaption

Created by team teamRed on July 10, 2026
Video Captioning

GemmaCaption captions video clips in four styles (formal, sarcastic, humorous_tech, humorous_non_tech) with no external model APIs and no credentials: gemma-4-E2B-it (QAT Q4_0 + vision projector) runs entirely inside the container via llama.cpp, on the grading VM's 2 CPU cores in under 4 GB RAM. Gemma writes every word the judge reads. Making a 5B-class multimodal model do this in a 10-minute budget took four tricks. (1) Resolution-aware frame layouts: the vision encoder resizes input to a fixed square, so a 2x2 frame collage arrives at quarter resolution — four frames as two hi-res vertical strips scored 0.841 vs 0.781 on our 16-clip benchmark; the agent measures its own call latency at runtime and picks strips or collage per clip, whatever the budget affords. (2) Tiled frames mean one encoder pass instead of four. (3) The prompt precedes the image, so llama.cpp's prefix cache never re-processes it. (4) Grammar-constrained decoding: each request carries a JSON schema built from that task's styles, guaranteeing exact keys — plus the discovery that Gemma 4, a thinking model, silently pours grammar-constrained output into its reasoning channel unless reasoning is disabled server-side. The whole development loop was Gemma on AMD: gemma-4-26B-A4B-it captioned 636 Wikimedia clips on an AMD Instinct GPU (ROCm) to distill a LoRA fine-tune of E2B, and the same 26B judged every experiment. Its verdict: the grammar-constrained official weights beat our fine-tune 0.887 to 0.855, so the shipped image runs them — we kept the honest result; the full fine-tune pipeline ships in the repo. Reliability: downloads and ffmpeg overlap the serialized Gemma calls; a global budget with cost-aware gates guarantees exit before the kill; results.json is written incrementally and atomically, so a hard kill at any instant still leaves a complete valid file. Validated: 12 clips in 539.5 s of the 600 s budget, 12/12 real captions, ~2.9 GB peak memory.

Category tags: