Spatial References in Visual Reasoning: Embedding Coordinates into the Chain of Thought

    Explicit spatial markers such as bounding boxes and points can bridge the gap between language and image regions in multimodal reasoning. This article explains how coordinate annotations support object counting, path tracing, and spatial consistency, along with the model architecture, coordinate conventions, and generation workflow required to use them effectively.

    1. The Problem: A Gap in Visual Reference

    In complex visual reasoning tasks, many model failures originate from reference resolution. A model may recognize the objects in an image but still fail to ensure that every reasoning step refers to the same object. Typical examples include counting people in a scene, following a curve to its endpoint, and determining whether a maze contains a valid path. These tasks require multiple reasoning steps, and each linguistic description must correspond to a specific region in the image.

    When this correspondence exists only implicitly in the attention distribution, even a slightly longer reasoning chain can introduce several problems:

    • Object confusion: Attributes belonging to two similar individuals may be incorrectly assigned to the same person.
    • Missed or duplicate counts: Occluded objects may be skipped, or the same object may be counted more than once.
    • Spatial drift: A region described as “upper left” in one step may refer to a different location in the next.

    This issue can be described as a reference gap: language references lack an explicit connection to concrete positions in the image.

    2. Core Idea: Add Spatial Markers to the Chain of Thought

    When counting objects in a scene, people often point to each object one by one. The finger indicates the location receiving attention and provides an anchor for subsequent counting. Applied to a model, this idea becomes the insertion of explicit spatial markers into the chain of thought. These markers act as precise pointers between language and image regions.

    Spatial markers generally take two forms:

    1. Bounding boxes: Describe an object’s extent and are suitable for object counting and region-based judgments.
    2. Points: Identify a specific location and are useful for fine-grained cases such as curve endpoints and maze entrances.

    Each marker contains two components: a placeholder name and coordinates. The placeholder name can be referenced repeatedly during later reasoning, ensuring that the language continues to point to the same object. A neutral example format is shown below; individual projects can adapt it to their own conventions:

    1. <ref>pedestrian</ref><box>[[120,85,198,260],[310,92,372,265]]</box>
    2. <ref>entrance</ref><point>[[38,512]]</point>

    A later reasoning step could state: “There are two pedestrians, and both are located in the central part of the image.” Because the placeholder name remains unchanged, the model has an anchor that can be checked against the image.

    The coordinate convention must remain consistent during both training and inference. Two common approaches are normalizing coordinates to a fixed integer grid, such as 0 to 1000, or using pixel coordinates from the original image. Normalization decouples coordinates from input resolution, making it easier to process images of different sizes.

    3. Model Architecture: A General Three-Part Design

    A multimodal model typically consists of three components:

    • Vision encoder: Splits the image into patches and encodes them as visual tokens.
    • Projection layer: Maps visual features into the representation space of the language model.
    • Language model: Receives the combined image-and-text token sequence and generates text containing both the reasoning process and spatial markers.

    To support arbitrary image resolutions, common approaches include dynamic tiling or encoding images according to their original aspect ratios in combination with positional encoding. High-resolution images produce a large number of visual tokens, creating two major costs: higher attention-computation overhead and significantly greater KV-cache usage during inference.

    For this reason, engineering implementations often apply pooling, token merging, or importance-based pruning to visual tokens. Stronger compression generally causes greater detail loss, with small-object localization being affected first. The appropriate compression level should be determined through evaluation rather than by looking only at the compression ratio.

    4. Generating Spatial Markers in the Chain of Thought

    The model must learn to output spatial markers at the appropriate points in the reasoning process. A valid reasoning trajectory generally follows this sequence:

    1. Declare the object.
    2. Provide its coordinates.
    3. Refer to the placeholder name in subsequent steps.
    4. Reach a conclusion based on the marked locations.

    The following is an example fragment for a maze-evaluation task:

    1. Step 1: Locate the entrance. <ref>entrance</ref><point>[[38,512]]</point>
    2. Step 2: Move along the passage toward the upper right.

    In this workflow, the point identifies the entrance explicitly, while the placeholder name provides a stable reference for later reasoning. The same principle can be applied to object counting, path tracing, and other visual tasks in which maintaining spatial identity across multiple reasoning steps is essential.