How to Evaluate Spatial Reasoning in Large Language Models
Spatial reasoning means keeping coordinates, scale, occlusion, relative position, and motion consistent without continuous visual feedback, then turning those constraints into runnable scene descriptions or generation scripts. This article explains why text-only questions are a weak test, and how to score models with scene graphs, geometric assertions, fair comparisons, constrained creative tasks, and regression sets that reflect real delivery quality.
Spatial reasoning is the ability to keep a coordinate frame, scale, occlusion, relative orientation, and motion timing consistent without continuous visual feedback, and to express those constraints as a runnable scene description or generation script. It is not the same as being able to talk about 3D concepts. Reciting terminology is enough for the latter. The former requires objects to appear in the right places, the camera to actually see the key structure, and animation to avoid intersecting solid geometry. For intelligent programming, visual teaching, digital twins, and creative content production, this capability is closer to real delivery quality than a single-turn Q&A score.
Why Text Questions Are Not Enough
A common evaluation asks the model whether A is in front and to the left of B. The model can score well from language patterns while still hiding errors such as left-handed versus right-handed coordinates, mixed units, or stacked parent-child transforms. A more reliable approach is to narrow the task to an executable artifact: a scene graph, a parametric script, or a keyframe sequence. A shared runtime then renders it or computes bounding boxes. Success should depend on whether geometric constraints are satisfied, not on how confident the explanation sounds.
Split tasks into four levels:
- Static layout. Given room and furniture dimensions, plus constraints such as against the wall, leave a passage, and no mutual overlap.
- Viewpoint and occlusion. The main object must be fully visible from a specified camera, while background objects show only part of themselves.
- Timing. An object moves along a path, keeps its heading through turns, and has start and end frame positions that can be checked.
- Creative programming. Within hard constraints and a limited set of primitives, produce a shot with a narrative or teaching purpose.
The first three levels measure stability. The fourth measures the ability to organize complexity inside constraints, so stacking visual effects is not mistaken for spatial understanding.
Separate Reasoning from Implementation with a Scene Graph
If the model emits low-level drawing calls directly, library interfaces, matrix order, and business constraints get tangled together, and failures are hard to locate. A two-stage flow is more stable. First, output a scene graph that does not depend on a specific runtime: nodes, parent-child relations, translation, rotation, scale, material categories, and camera and light parameters, all with explicit units and a declared right-handed or left-handed coordinate system. A controlled template then translates the scene graph into an executable script. Scoring then falls mainly on spatial decisions rather than on memory of one graphics API.
A scene graph should at least include world units (meters or normalized units), a bounding box for each mesh, whether the anchor is the center or the bottom face, rotation order, camera field of view and near and far clip planes, and the time unit of animation curves. Without these fields, two results that both “generated successfully” cannot be compared.
An example structure:
scene:unit: meterup: [0, 1, 0]nodes:- id: tablesize: [1.6, 0.75, 0.8]position: [0, 0.375, 0]- id: camera_mainlook_at: tableposition: [2.2, 1.4, 2.8]fov_deg: 40constraints:- no_overlap: [table, chair]- visible: {object: table, camera: camera_main, min_ratio: 0.8}
Automatic Checks Must Cover Geometry, Not Just Whether It Runs
A script that runs only shows that syntax and dependencies are basically correct. Spatial tasks need a repeatable set of assertions.
- Bounding boxes and collision. Transform each object into world coordinates, then compute an axis-aligned or oriented bounding box. Overlap volume above a threshold is a failure. Passage constraints can be checked with sample points or a simplified navigation mesh for connectivity.
- Relative relations. Define “left of,” “above,” and “inside” as computable predicates and declare tolerances. “A is to the left of B” should require both a lateral coordinate difference and an orientation reference, so the model cannot claim success after a tiny move.
- Scale consistency. Do not mix centimeters and meters in the same task. If the prompt gives real-world sizes, measure error relative to the nominal size, not in absolute pixels.
- Visibility. Cast rays from the camera or use a depth buffer. Measure the target’s projected area as a share of the frame and the occluded share. Thresholds for “close-up” and “wide shot” must be written into the score sheet in advance.
- Timing. Sample position, speed, and heading at keyframes. Sudden speed jumps, start or end points that drift, and objects that still penetrate solids after a collision should each be recorded as a separate error type.
- Resources and safety. Evaluation scripts must not access external networks, read unrelated paths, or run system commands unrelated to the scene. Limit runtime, memory, and recursion depth.
Classify failures instead of collapsing them into one vague score. At a minimum, distinguish: no executable result, invented interfaces, coordinate-system errors, scale errors, occlusion errors, missed constraints, animation out of sync, and timeouts from excessive complexity. Classification shows whether the weakness is spatial understanding, instruction following, or engineering robustness.
Fair Conditions for Comparison
To compare models, or different prompts for the same model, lock the task pack, runtime, random-seed policy, timeout, and number of allowed repair rounds. Archive the initial prompt, added constraints, and error feedback verbatim. Letting the model revise once after a compile or assertion failure is reasonable, because real development works that way. Do not count a success if a person edits coordinates for the model.
Split scoring into hard and soft scores. Hard scores look only at constraint assertions: pass means points, and polished prose adds nothing. Soft scores look at whether the structure is clear, names are maintainable, the goal is met with few primitives, and the camera serves the intended expression. Soft scores need two-person blind review and a rule for resolving disagreements. Do not replace a distribution with one flashy sample. Prepare multiple isomorphic tasks with different surface details in each category, and keep a private regression set so prompts cannot be memorized against the test.
How to Write Prompts and Intermediate Constraints
An effective prompt states the coordinate system, units, output format, prohibitions, and acceptance criteria. It should not only say “make a scene with a strong sense of space.” Putting acceptance criteria in the prompt tests whether the model can follow a specification. Leaving them out tests whether the model can fill in common sense on its own. Both are useful, but they must be reported separately and not merged into one capability claim.
For complex scenes, you can require the model to list objects and a constraint checklist before writing the scene graph. This is not a substitute for the result in the form of a long explanation. It is for audit: a mismatch between the list and the final nodes is itself an error. In repair rounds, return only failed assertions and a short error summary. Do not leak a full reference answer to the model.
Creative Programming Should Stay Constrained
Pure showcase generation easily piles up particles, random colors, and camera moves that cannot be checked. If the goal is to express structure, set a primitive budget, a duration, the spatial relations that must appear, and a rule that text textures must not replace geometry. When explaining an assembly, parts must separate and return along a clear axis, not merely flash a label on screen. Compute the creative score only after every hard constraint passes, so visual noise cannot hide geometric failure.
Common Pitfalls in Engineering Practice
A frequent failure is correct local coordinates and wrong world coordinates after parent-child transforms stack. Inconsistent anchors make objects sink into the floor or float. If the camera near clip plane is too large, nearby objects are cut off while the model may still claim a complete view. If animation uses frame numbers and checks use seconds, timing tasks fail as a group. Another class of problem is invented functions or parameters. Runtime failure should be recorded as interface robustness, not dropped from the statistics, or usability will be overstated.
Fix the evaluation runtime in an internal image and record dependency versions. Once the graphics backend, numeric precision, or default coordinate system changes, historical scores are no longer comparable. Logs should at least keep the input, scene graph, assertion results, and rendered keyframes for review. Do not write secrets or production data into logs.
How to Read Results and Use Them for Selection
A high spatial-reasoning score only means geometric constraints are more stable on a given task distribution. It does not automatically mean better code style, long-document understanding, or domain knowledge. Weight by scenario: layout and path planning by hard-constraint pass rate; interactive edits by the gain in pass rate after multi-round repair and by whether new errors appear; creative content by completeness of expression inside constraints. A model that fails on the first try but reliably fixes itself from assertions may be more useful in engineering than one that looks impressive once and collapses on the second try.
Make this a continuous regression, not a one-off demo, if you want to see real variation from prompts, runtimes, and task difficulty. Teams that need 3D results should start with a small, hard constraint set, then add occlusion, animation, and creative tasks. Discussion of spatial ability has a basis only when every task can be checked quantitatively.
