LLM Selection and SVG Prompt Testing: A Practical Guide
This article explains how to select large language models for SVG generation by matching task complexity, prompt constraints, model tier, and reasoning effort. It provides a structured SVG prompt template covering coordinate, structural, contact, output, and self-check constraints, along with a routing table for lightweight, standard, and flagship models. It also outlines a repeatable testing method and cost accounting approach based on acceptance pass rate, token usage, latency, and failure types, so routing decisions can be based on measured results rather than impressions.
1. How to Determine Whether a Task Is Complex
The feeling that an “upgrade is actually a downgrade” often comes from a mismatch between the task and the model. Task complexity can be judged along four dimensions: number of constraints (the number of rules that must be satisfied simultaneously), reasoning span (how many interdependent derivation steps are required), output scale (lines of code, number of coordinate points, or canvas size), and acceptance method (whether there are automatically checkable criteria). A task that meets two or more of these dimensions can be considered complex and requires a stronger model and more complete constraints.
For the same request, changing only the strength of the constraints can produce very different results. If the prompt only says “generate SVG code for a pelican riding a bicycle,” the model may output a plausible-looking image, but it is often not guaranteed that the frame tubes connect to each other or that the positional relationship between the pedals and the seat is valid. This type of problem does not necessarily come from insufficient model capability; more often, the instruction does not provide checkable criteria.
Therefore, when evaluating models, first fix the task tier and prompt, and then compare the output results. Conclusions such as “the new version is stronger” or “the old version is weaker” are meaningless when detached from the task conditions.
2. Structured SVG Prompt Template
The following template divides constraints into five categories. Replace the bracketed content when using it.
Task: Generate an SVG of [width]×[height] whose visual subject is [subject].
- Coordinate system: The canvas origin is at the top-left corner, and the unit is pixels. First list the coordinates of key parts, including [list of parts].
- Structural constraints: All parts of [object] must conform to [structural description]. For example, a bicycle frame consists of triangles: first determine the front and rear wheel centers, then sequentially derive the endpoints of the bottom bracket, seat tube, and down tube. Adjacent tubes must meet at shared nodes, and dangling endpoints are not allowed.
- Contact constraints: All load-bearing points and contact points must lie on the corresponding support surfaces, for example [list of contact points]. No floating limbs, detached beak, or parts disconnected from components are allowed.
- Output constraints: Output only one complete SVG code block, with no explanatory text. Use semantic IDs for elements to facilitate later checks.
- Pre-output self-check: Verify the above constraints one by one, confirm that the endpoints of each part are connected, that contact point coordinates lie on the support surfaces, and that the viewBox is consistent with width and height. Fix any issues before outputting the final code.
The self-check list is best given to the model as a second-round review, or it can be executed by a script. Every self-check item should be verifiable, for example, “the endpoint error of the three main frame tubes does not exceed the set pixel threshold.” The threshold should be determined by canvas size and purpose; there is no universal standard.
3. Model Tiers and Reasoning-Effort Routing
Whether a reasoning effort parameter (Effort) exists depends on the provider and the specific model. Some APIs provide this parameter, while others can only control it indirectly through maximum output length, reasoning budget, or temperature. Before selecting a model, check the documentation for the API you are using, confirm which parameters are available, and then apply the routing approach below.
| Task type | Complexity signal | Recommended model tier | Reasoning effort | Acceptance metric | Failure fallback |
|---|---|---|---|---|---|
| Code completion, simple summarization, basic Q&A | Single constraint, short output | Lightweight model | Low, using default configuration | Response time, format correctness rate | Escalate to standard model and retry |
| Routine business code generation | Two to three constraints, output within a few hundred lines | Standard model | Medium | Unit test pass rate | Add constraints and retry |
| Architecture design, multi-step reasoning, high-precision SVG or Canvas | Four or more constraints, coordinate or dimension validation required | Currently available flagship model | High, together with self-check prompt | All self-check items pass, script checks pass | Split into subtasks and generate in stages |
One point to note when routing: high reasoning effort cannot replace clear constraints. A simple prompt combined with high effort often causes the model to overinterpret the request, producing longer output without improving accuracy. Effort should match the strength of the prompt constraints.
The performance of lightweight models on high-constraint tasks also needs to be confirmed through testing. If failures occur when structured constraints are not provided or when the output size is very large, record the specific failure type and rely on the actual model version and test conditions rather than drawing conclusions from impressions.
4. Testing Method and Cost Accounting
Any conclusion about differences between model versions should be supported by your own test data. The following steps are recommended.
- Fix the test set: Prepare 20 to 50 tasks of the same type, covering simple, medium, and complex tiers.
- Fix the prompts: Use the same set of prompts for all candidate models, changing only the model name and reasoning parameters.
- Record metrics: For each call, record the model version, input token count, output token count, reasoning token count returned by the API (if any), latency, retry count, and whether acceptance was passed.
- Use a unified cost basis: Calculate cost based on the actual billed total tokens, including tokens generated during reasoning and tokens generated by retries. When comparing, use “average cost per accepted result” rather than the list price per call. Billing rules differ by provider; refer to the official billing documentation.
- Distinguish failure types: Timeouts, incomplete SVG output, failed self-check items, and failed structural checks should be counted separately so you can determine whether the problem lies in the model, the prompt, or the parameters.
Test results can be organized as shown below. For cells where testing has not been completed, keep “Pending measurement”; do not fill them with estimated values.
| Model version | Task tier | Acceptance pass rate | Average output tokens | Average latency | Main failure type |
|---|---|---|---|---|---|
| To be filled | Simple | Pending measurement | Pending measurement | Pending measurement | Pending measurement |
| To be filled | Medium | Pending measurement | Pending measurement | Pending measurement | Pending measurement |
| To be filled | Complex | Pending measurement | Pending measurement | Pending measurement | Pending measurement |
If model calls need to be integrated into enterprise systems, you can use the container platform and monitoring and alerting services provided by a cloud provider. Set alert thresholds based on token consumption, response latency, and failure rate, and then adjust routing rules based on test results. The choice of which service to use should be based on the enterprise’s existing technology stack; this article does not recommend a specific vendor.
5. Conclusion
Model selection should start from the task itself. First use the four dimensions to judge complexity, then use structured prompts to state constraints clearly, and then allocate model tiers and reasoning effort according to the routing table. Finally, use a fixed test set to record pass rate, token usage, and latency, replacing subjective impressions with measured results. This approach avoids paying high costs for simple tasks while also achieving stable output quality on complex tasks.
