Evaluating Spatial Reasoning in LLMs: A Practical Guide to Parametric 3D Generation

    This article presents a practical framework for evaluating the spatial reasoning capabilities of large language models through parametric 3D generation. It explains why generating runnable code does not prove spatial understanding, how to design evaluations that are runnable, parametric, and automatically verifiable, and how to structure prompts around global constants, structural constraints, and acceptance checks. It also covers common failure modes, single-variable perturbation testing for root-cause analysis, and a reusable evaluation workflow that engineering teams can adopt for 3D generation, creative coding, and automated modeling benchmarks.

    1. Background: Why “Generating Code” Is Not the Same as Spatial Reasoning

    When evaluating the generation capabilities of large language models, a common mistake is treating “can it output runnable code?” as the ceiling of capability. In reality, whether code runs only proves that syntax and API calls are correct. Spatial reasoning tests whether a model can maintain a self-consistent 3D constraint system in its head: the relative positions of parts, transmission relationships, phase consistency, and whether the entire geometry can be recalculated in sync when a key dimension changes.

    The original practice moved away from a browser-based 3D rendering library approach toward scripted modeling for one core reason: rendering libraries excel at visual presentation, but they make it easy for a model to focus on “looking right” rather than “computing correctly.” Scripted modeling requires the model to explicitly declare geometric sources and dependencies, so any spatial error is exposed immediately when parameters change.

    2. Evaluation Design: Turning “Spatial Sense” into Verifiable Propositions with Parameter Linkage

    A high-quality spatial reasoning evaluation should meet three conditions: runnable, parametric, and automatically verifiable. Runnable means the deliverable can execute in an unattended mode. Parametric means key dimensions and state variables must be centralized in a top-level constants section. Automatically verifiable means the evaluator does not need to understand the model’s internal logic and can judge results by changing numbers only.

    A recommended global constants design (illustrative):

    1. # Global constants section: all geometry must be derived from here
    2. WINGSPAN = 1.15 # Wingspan; controls handlebar width and grip spacing
    3. WHEELBASE = 1.02 # Wheelbase; drives frame geometry
    4. CHAINRING_TEETH = 44 # Chainring teeth; determines chain length and gear ratio
    5. COG_TEETH = 16 # Rear cog teeth
    6. CRANK_PHASE = 35.0 # Crank phase angle; determines pedal and foot contact

    The acceptance procedure is clear: modify only three values—wingspan, chainring teeth, and crank phase—without touching any function body, then rerun and check three things. First, whether the handlebar widens with the wingspan while the grips still enclose both wing tips. Second, whether the chain path is correctly recalculated after the chainring is enlarged, without clipping through geometry or hanging in the air. Third, whether the support foot still contacts the pedal surface after the phase changes, and whether the return foot remains at the low position.

    The value of this design is that it translates the vague notion of “spatial sense” into three decidable propositions. If a model only hardcodes values inside functions, changing a parameter causes immediate clipping. Only by genuinely establishing parameter dependencies can it pass acceptance.

    3. Prompt Engineering: Writing Narrative, Constraints, and Acceptance into One Requirement

    An evaluation prompt should contain four layers of information. The first layer is scene narrative, which gives the model a unified target image—for example, a pelican leaning forward and riding along a seaside promenade at dusk, wings extended forward to grip the handlebar, one foot on the pedal and one foot hanging at the lowest point of the return stroke. The second layer is structural constraints, specifying a classic diamond frame, a tool bag hanging from the down tube, a fishing net strapped to the rear rack, and a transmission system in a tensioned driving state. The third layer is parameter linkage requirements, emphasizing that all geometry must be derived from global constants and prohibiting disconnected magic numbers inside functions. The fourth layer is acceptance instructions, informing the model in advance of the modifications and checks the evaluator will perform.

    The key to this approach is prioritizing “parametric verifiability” over “stylistic expression.” Artistic treatment is allowed, but the spatial relationships between parts must be verifiable by script.

    4. Common Failure Modes and Root-Cause Attribution

    The first type is visual-first bias: the model prioritizes good-looking rendering while ignoring transmission phase and foot contact, resulting in a pose inconsistent with the mechanical state. The second type is hardcoded dependencies: the geometry looks correct, but dimensions are written inside functions, so the whole structure collapses after a parameter change. The third type is chain and chainring disconnection: after the chainring tooth count changes, the path is not recalculated, causing hanging or clipping. The fourth type is missing constraints: only the frame and wheels are implemented, ignoring the spatial relationships of accessories such as the tool bag and fishing net with the main structure.

    For attribution, a “single-variable perturbation test” is recommended: change only one constant at a time and observe whether the affected parts change in sync. This helps locate whether the model lacks dependency modeling or lacks geometric solving ability.

    5. A Reusable Evaluation Workflow

    1. Fix the runtime environment to headless background execution to eliminate interference from a rendering window.
    2. Design three comparison generation tasks that separately assess spatial relationships, parameter linkage, and creative coding.
    3. Change only one variable per group and record whether it passes the three acceptance propositions.
    4. Classify failed samples by root cause to build a capability radar chart.
    5. Consolidate the prompt template and constants-section specification into a team standard to ensure cross-model comparability.

    6. Conclusion

    Evaluating spatial reasoning should not stop at “does it look right?” but should be upgraded to “is it still correct when parameters change?” Converging key dimensions, gear ratios, and phase angles into global constants and using single-variable perturbation for automated acceptance is the dividing line between “writing code” and “building a model.” For teams that want to build an internal evaluation system, this method can be directly transferred to scenarios such as 3D generation, creative coding, and automated modeling. Combined with general cloud capabilities such as container platforms, logging services, and monitoring alerts, the evaluation pipeline can also become an engineering asset that supports continuous regression.