LLM Code Generation in Practice: Spatial Reasoning Gaps and Better Evaluation Methods
This article presents a hands-on evaluation of how current large language models handle code and graphics tasks, focusing on a common "uneven skill" pattern: strong benchmark scores that do not translate into reliable engineering output. Through two real SVG animation tasks, it shows where models fail on spatial consistency and multi-body coordination, how visual feedback helps, and why first-frame checks are not enough. Readers will find a reusable evaluation checklist, a closed-loop testing workflow, and practical engineering recommendations for turning "looks good" into "works reliably."
1. Why a High Benchmark Score Does Not Mean It Works Well
As large language models iterate quickly, many teams still rely on public leaderboards when selecting a model. However, benchmark tasks are usually static, single-turn, and short in context, while real development scenarios often have three characteristics: long context, frequent tool calls, and vague requirements. This creates a familiar gap: a model that performs well on a leaderboard can show clear unevenness when applied to a concrete engineering task.
This article does not draw benchmark-style conclusions. Instead, it uses a few real tasks for an experience-based evaluation. A boundary must be stated first: the complexity, context length, and tool-call chains differ greatly across use cases. The judgments below apply only to these specific runs and should not be treated as a model capability ranking.
All evaluations used the same setup: maximum reasoning effort, standard mode, and no extra scaffolding optimization, to keep comparisons fair.
2. Use Case 1: The “Spatial Orientation” Weakness in SVG Animation
The task was simple: generate an HTML page with a 2D SVG animation of “a pelican riding a bicycle.”
The first output exposed two types of problems:
- An obvious semantic error: the pelican’s “hands” were not on the handlebars, and no constraint was established between the limbs and the vehicle;
- A hidden orientation error: the pelican was facing the wrong direction relative to its movement.
To test whether the model could self-correct, an image recognition plugin was connected to the coding tool so it could “look at the image, locate the problem, and fix the code.” The result was typical: the model spotted the obvious “hands not on the handlebars” issue but missed a problem that is immediately visible to human common sense: the reversed orientation. After a manual hint, it could locate and correct it.
A reproducible verification snippet:
<!-- Key constraints: orientation matches movement direction; limb endpoints bound to handlebars --><g id="pelican" transform="scale(-1,1)"> <!-- Flip this group if orientation is wrong --><path id="wing" d="..." /></g><g id="handlebar">...</g><!-- Animation: pedal circular motion --><circle id="pedal" r="6"><animateTransform attributeName="transform" type="rotate"from="0 0 0" to="360 0 0" dur="1.2s" repeatCount="indefinite"/></circle>
Conclusion 1: Current models have some self-checking ability for a single prominent defect, but insufficient sensitivity to global spatial consistency. External visual feedback and explicit constraint hints are needed.
3. Use Case 2: Multi-Body Coordination and Kinematic Plausibility
When the same task was given to another general-purpose model that keeps evolving, the output quality differed: the main body was slightly thin, but the orientation was correct, the limbs made contact with the handlebars, and the legs followed the pedals in circular motion. The kinematic relationships were coordinated.
This suggests that the difficulty of graphic animation tasks is not “drawing something that looks right” but “constraint satisfaction”: contact constraints, orientation constraints, and periodic motion constraints must all hold at the same time.
Recommended evaluation checklist:
- Orientation/coordinate system: whether the subject’s forward vector matches the direction of displacement;
- Contact constraints: whether hand/wing endpoints are bound to the handlebars and feet are bound to the pedals;
- Kinematics: whether the legs perform closed-loop circular motion rather than translational jitter;
- Visual regression: render the animation and spot-check frame by frame, instead of only looking at the first frame.
4. Rethinking Evaluation: From “First Frame” to “Closed-Loop Verification”
For an experience-based evaluation to be reusable, subjective impressions must be turned into a process:
- Layered use cases: score semantic, spatial, motion, and tool-call categories separately so a total score does not hide unevenness;
- Visual closed loop: generate, render, recognize, locate, and fix, for at least two rounds;
- Minimal hints: first give no answer and observe spontaneous correction; then give the minimum necessary hint and observe the ability to follow;
- Record cost: log rounds, latency, and failure modes, not just “success/failure.”
Illustrative workflow:
prompt -> code -> render -> vision-check -> patch -> render(loop)
5. Engineering Recommendations
- Make constraints explicit: write “orientation, contact, periodic motion” as verifiable assertions and include them in CI;
- Dual-channel verification: run static rules (structure/attributes) and dynamic vision (rendered frames) in parallel;
- Feed failure samples back: turn missed detection types into regression cases and continuously monitor whether unevenness converges;
- Keep cost under control: at high reasoning effort, limit context length and tool-call counts; when necessary, use object storage to save artifacts and use logging services and monitoring alerts to track failure rates.
6. Summary
The new generation of large language models is “usable” for code and graphics tasks, but still uneven in spatial consistency and multi-body coordination. Model selection should not rely only on leaderboards. Instead, build a closed-loop evaluation oriented to real tasks: layered use cases, visual self-checking, minimal hints, and cost recording. Only then can “looks good” become “engineerably reliable.”
