How to Measure the Gap Between Open-Source and Closed-Source LLMs: A Video Code Generation Example
This article explains how to compare open-source and closed-source large models with a controlled, reproducible evaluation rather than impressions or isolated demos. Using a task that asks a model to generate a webpage animation and render it into a video, it covers three capabilities: code generation, long-text understanding, and tool invocation. It describes how to set up a consistent test environment, write deterministic animation code, render frames, verify output pixel by pixel, and score results across five dimensions. It also addresses common issues and explains how to interpret results for practical model selection.
1. Why Compare Open-Source and Closed-Source Models
Open-source and closed-source models each have advantages. Open-source models usually facilitate private deployment, keep data within the domain, and support fine-tuning as needed, making them suitable for privacy- and cost-sensitive scenarios. Closed-source models are usually continuously iterated by the provider, perform more stably on general tasks, and are easier to integrate. When selecting a model, teams often ask: how large is the capability gap between the two types?
If this question is answered only by impression, the conclusion is easily distorted. A single impressive demo or a pleasant conversation is not enough to represent overall performance. To obtain a reliable judgment, you need to define the comparison scope first and then measure with unified tasks and metrics.
This article focuses on three capabilities:
- Code generation: Whether the model can write structurally correct code that runs directly from natural-language requirements.
- Long-text understanding: Whether the model can find all requirements in a long specification and implement them one by one.
- Tool invocation: Whether the model can correctly initiate calls according to an interface contract and handle returned results and errors.
These three capabilities are interrelated in real engineering work. A model that can write code but cannot read the full requirements still produces output that requires substantial rework.
2. Choose a Reproducible Test Task
An evaluation task needs to satisfy three conditions at the same time: clear input, an observable process, and output that can be verified objectively.
“Ask the model to write a webpage animation and then render it into a video” satisfies these conditions. Its characteristics are as follows:
- It covers all three capabilities. The model must understand multiple requirements such as layout, duration, and transitions (long-text understanding), write the page structure and animation logic (code generation), and invoke the rendering and export workflow to complete delivery (tool invocation).
- The result can be verified. Every frame in the final video can be compared with the webpage image at the corresponding moment, so questions such as “was a frame dropped” and “was the output produced at the required duration” have clear answers.
- The scale can be adjusted. You can first use a 3-second clip to validate the workflow, then extend it to a complete clip of 20 seconds or more.
3. Build a Unified Test Environment
The premise of a comparative experiment is controlling variables. Each test round should fix the following:
- The task description and prompt template, kept verbatim consistent.
- Sampling parameters, such as temperature and maximum output length.
- The runtime environment, including operating system version, runtime version, and rendering component versions.
- The test time and model version number, because the provider may update the model without notice.
A rendering environment usually contains three parts: a package manager for installing dependencies, a headless browser for executing page scripts and taking screenshots, and an audio/video encoder for combining an image sequence into a video.
For frame-by-frame animation in a webpage, the key is to ensure that the animation is determined by a time parameter. Below is an illustrative implementation:
<div id="scene" style="width:1080px;height:1920px;background:#111;"><h1 id="title" style="opacity:0;color:#fff;">Product Launch</h1></div><script>// Use time t (in seconds) as a parameter to determine the visual state of the current framefunction renderAt(t) {const el = document.getElementById('title');const progress = Math.min(t / 1.0, 1); // Complete fade-in in the first 1 secondel.style.opacity = progress.toFixed(3);}window.renderAt = renderAt;</script>
This code has one key point: the animation state is fully determined by the parameter t, without reading system time or using random numbers. If the code depends on real time or random values, the same frame will differ on each render, and the test result cannot be reproduced.
4. Frame-by-Frame Rendering and Result Verification
The rendering workflow can be split into three steps: set the time, take a screenshot, and compose the video. The following pseudocode illustrates the workflow structure; the specific wrapper depends on the environment:
const fps = 30;const totalFrames = seconds * fps;for (let i = 0; i < totalFrames; i++) {const t = i / fps;await page.evaluate((t) => window.renderAt(t), t);await page.screenshot({ path: `frames/${String(i).padStart(5, "0")}.png` });}// Then call an encoding tool to combine the frames directory into a video file
After rendering is complete, the result needs to be verified. The verification method is to capture a frame in the webpage, extract the frame with the same index from the exported video, and then compare them pixel by pixel. If the two images are identical, the frame was not lost and was not misaligned.
const diffPixels = countDifferentPixels(frameFromBrowser, frameFromVideo);if (diffPixels !== 0) {throw new Error(`Frame ${frameIndex} has ${diffPixels} mismatched pixels`);}
In practice, you can spot-check the first frame, a middle frame, and the last frame, because effects such as transitions and fade-outs often appear at these positions.
5. Design Scoring Dimensions
Looking only at whether the task runs is far from enough. It is recommended to record results across the following five dimensions, with a clear measurement method for each dimension:
| Dimension | Measurement Method | Description |
|---|---|---|
| Code runnability | Whether the first generated code executes without errors | Reflects basic code generation capability |
| Requirement coverage | The proportion of requirement items that are correctly implemented | Reflects long-text understanding capability |
| Structural correctness | Whether duration, resolution, and transition order match the requirements | Reflects grasp of specification details |
| Tool invocation success rate | Whether rendering and export calls succeed on the first attempt and whether parameters are valid | Reflects tool invocation capability |
| Repair rounds | How many feedback rounds are needed to pass after an error occurs | Reflects self-correction capability |
When recording results, save the complete prompts, model outputs, error logs, and final videos. These materials are more valuable than a single score during retrospectives.
6. Common Issues and How to Handle Them
Missing environment dependencies. Run an environment check before testing to confirm that the runtime, package manager, and headless browser are ready. Add whichever is missing and record the version number.
Security interception and deletion operations. When cleaning old dependencies, automation tools may trigger a security prompt for bulk deletion. The principle is to inspect the objects to be deleted first. If they are dependency cache directories, you can allow the operation after confirmation; if user documents or unexpected files are involved, you should reject it and check the source of the operation.
Rendering takes too long. First validate the workflow with a short clip, and render the full version only after confirming that everything is correct. This avoids waiting for a long render every time you make a change.
Unstable animation. If the same frame produces different results across multiple renders, the animation usually depends on real time or random values. It should be changed to a deterministic implementation driven by parameters.
Model output exceeds permissions. When commands generated by the model include deletion, overwriting, or permission changes, they should be manually confirmed before execution. Tool invocation should follow the principle of least privilege, exposing only the operations required by the task.
7. How to Interpret Test Results
The result of a single task cannot represent an overall ranking. A reasonable approach is:
- Use multiple tasks and multiple runs. Prepare several samples for each task type, run each sample multiple times, and report the range of variation in the results.
- Compare by capability. The gap between the two types of models is often concentrated in certain dimensions, such as coverage of complex requirements, while the gap in simple code generation is smaller. The gap should be broken down rather than reduced to a single total score.
- Incorporate business weights. If the business values structural correctness most, the weight of that dimension should be increased.
- Consider cost and constraints together. Inference latency, cost per call, data compliance requirements, and deployment flexibility all affect the final choice. The highest-quality option is not necessarily the most suitable one.
8. Implementation Recommendations
Teams can build a small internal evaluation set containing 20 to 50 tasks that cover the three capabilities. Whenever a new model version is released, rerun the same set of tasks and save complete logs. The comparison results obtained in this way can reflect both the gap between models and the changes in the same model across different versions.
The purpose of evaluation is to support decisions, not to produce an attractive ranking. As long as the task design is reasonable, the metrics are clearly defined, and the process is reproducible, you can answer three practical questions: how large is the gap, where does it lie, and whether it is worth paying the cost for it.
