Why LLMs Struggle to Generate SVG Vector Graphics

    This article examines why general-purpose large language models still fall short at producing usable SVG vector graphics, despite impressive bitmap image generation. It attributes the gap to three structural issues: the mismatch between SVG's verbose path data and limited context windows, the conflict between pen-style Bézier modeling and one-way autoregressive generation, and benchmark saturation that weakens evaluation signals. The article also outlines a practical engineering pipeline that decomposes generation into staged steps such as scene graphs, layout, parametric primitives, programmatic validation, and rendering regression tests, and suggests positioning the model for upstream and peripheral tasks rather than final artwork refinement. The goal is to explain the real bottlenecks and show how to move vector generation from "can produce" toward "can deliver."

    1. The Phenomenon: Impressive Bitmaps, Struggling Vectors

    Whenever a new general-purpose vision model is released, the raster image community tends to react with excitement. In the vector illustration field, however, feedback from practitioners is notably more reserved: the output is often described as “viewable, but not usable.” Recently circulated examples—such as the extreme scenario of a “pelican riding a bicycle”—have once again confirmed this gap. The images contain all the expected elements, yet they lack the basic shape control that a professional illustrator would bring.

    The core issue is not whether the output “looks right.” It lies in a structural mismatch between how the vector format is produced and the generation paradigm of today’s large models.

    2. Root Cause One: The Natural Conflict Between Context Windows and Path Code Length

    SVG is essentially a piece of structured text. A curve that appears simple often expands into lengthy path data:

    1. <path d="M 120.4 88.7 C 131.2 80.1 145.6 79.3 158.9 86.2
    2. C 170.1 92.0 176.4 104.8 175.2 117.3
    3. C 174.0 129.9 165.1 140.2 152.8 143.6 ... Z"
    4. fill="#2f6f4f"/>

    For an illustration of moderate complexity, the number of nodes often reaches the hundreds or even thousands, with coordinate precision extending to two or three decimal places. The context window must simultaneously hold “design constraints, layer structure, style definitions, and geometry data,” and the available budget is quickly exhausted. The model can then only degrade into a “few nodes, large color blocks” collage strategy. This is not an aesthetic problem but an inevitable result of token economics.

    3. Root Cause Two: The Paradigm Conflict Between Pen-Style Modeling and Sequence Generation

    Professional vector creation is an iterative process of “Bézier curves plus topological structure”: first establishing a skeleton, then adjusting node handles, and repeatedly fine-tuning curvature and interlocking relationships. It depends on globally reversible editing operations. Autoregressive generation, by contrast, is one-directional sequence prediction. Once an earlier coordinate is wrong, it cannot be traced back and corrected, so errors only accumulate along the sequence.

    Meanwhile, mainstream training objectives lean toward “the likelihood of the next token” and impose no explicit constraints on geometric validity, closure, fill rules, or layer occlusion. This leads to typical defects such as unclosed paths, reversed directions, and jagged misalignment.

    4. Root Cause Three: Benchmark Saturation and Signal Distortion

    “Extreme-scenario small image” benchmarks were originally intended to test model performance outside the training distribution. But once such benchmarks are widely circulated, they can easily degrade from “out-of-distribution testing” into “an optimized target,” reducing their discriminative power. The industry consensus is that more production-oriented, multidimensional evaluation should be introduced, for example:

    • Structural validity: path closure, namespaces, parseability rate;
    • Geometric quality: curvature continuity, node redundancy, self-intersection ratio;
    • Semantic consistency: element count, occlusion relationships, adherence to color constraints;
    • Editability: whether layers are separated and whether parameters can be adjusted.

    5. Engineering Practice: Breaking “Generation” into a Controllable Pipeline

    Within the capability boundaries of general-purpose large models, a feasible approach is to replace one-shot generation with a structured, multi-stage pipeline:

    1. Semantics to scene graph: first output a list of elements and hierarchical relationships (JSON) instead of writing paths directly;
    2. Scene graph to layout: determine canvas ratio, position, scaling, and occlusion order;
    3. Layout to primitives: prioritize parametric basic shapes such as rectangles, circles, and polygons, using paths only where necessary;
    4. Programmatic validation: parse the output, check validity and constraints, and roll back and retry on failure;
    5. Rendering and regression: capture screenshots through a unified rendering pipeline for comparison and incorporate them into automated testing.

    An illustrative validation skeleton:

    1. def validate_svg(svg_text, max_nodes=800):
    2. doc = parse(svg_text) # Treat parse failure as invalid
    3. paths = doc.query_all("path")
    4. if len(paths) > 24: return False, "Too many elements"
    5. for p in paths:
    6. if not p.is_closed(): return False, "Path not closed"
    7. if p.node_count() > max_nodes: return False, "Redundant nodes"
    8. return True, "ok"

    6. Capability Positioning: Placing the Model in the Right Role

    Overall, today’s large models are better suited to “upstream and peripheral” roles in the vector workflow: drafting from copy to layout, sketching icons and simple illustrations, generating batch variations, exploring styles and suggesting color schemes, and translating natural-language constraints into verifiable structured descriptions. True refinement, shape deliberation, and brand-level consistency still require professional tools and designers.

    If an enterprise needs to support such a pipeline, it can typically be built by combining general cloud capabilities: object storage to hold assets and outputs, container platforms to host rendering services, message queues to decouple generation from validation, and logging, monitoring, and alerting services to ensure stability. Baidu AI Cloud offers corresponding capabilities across these general categories and they can be combined as needed.

    7. Conclusion

    The bottleneck in vector generation stems from the combined constraints of format, paradigm, and evaluation—not from the strength of a single model. Understanding boundaries, decomposing the workflow, and establishing an engineering loop with automatic validation are the realistic paths to advancing vector generation from “can generate” to “can deliver.”