Visual Primitives: From the Reference Gap to Spatial Reasoning in Multimodal Models

    This article explores how multimodal models overcome the "reference gap" in spatial reasoning tasks like dense counting and maze pathfinding. It details the mechanism of visual primitives—using spatial tokens such as points, boxes, and polygons—and compares this approach with classic natural language visual thinking. Additionally, it provides practical troubleshooting steps and configuration checklists to ensure consistent model performance across different environments.

    Multimodal models can now see fine image details, yet they still struggle with tasks like dense counting and maze pathfinding. The primary issue lies in the reasoning phase: models typically use natural language to refer to objects in an image, and vague descriptions can break the subsequent reasoning chain. This article clarifies the boundaries of this problem, introduces how the visual primitive approach works, and provides verifiable configuration and troubleshooting steps.

    1. The Boundary of the Reference Gap

    When Large Language Models (LLMs) are integrated with visual encoders, the first challenge is perception—seeing image details clearly. High-resolution encoding and Vision Transformers (ViTs) have largely mitigated this issue. The remaining problem is reference: the model must still use language to articulate “which object” during reasoning.

    These errors commonly occur in two types of tasks. The first is dense counting, such as counting individuals in a crowd one by one. The model must remember previously counted positions; the longer the language description, the more likely it is to omit or duplicate items. The second is spatial planning, such as maze pathfinding, where each step references the previous position. A single coordinate description error will invalidate the entire path.

    The reference gap and perception capability are two independent issues. If a model correctly identifies objects but repeatedly loses track of their positions during reasoning, the problem likely lies in the reference method. To verify this, provide only the image and a clear prompt, and observe whether the model outputs verifiable coordinates in its intermediate steps.

    2. Tokens and Coordinates of Visual Primitives

    The core of the visual primitive approach is enabling models to use unambiguous spatial pointers during reasoning, rather than relying solely on natural language. In implementation, a set of special tokens is added to the model’s vocabulary, typically including points, boxes, and polygons.

    • Points: Mark a single pixel position, suitable for counting and single-point localization.
    • Boxes: Define a target using four boundary values, suitable for detection and region reference.
    • Polygons: Describe irregular contours, suitable for segmentation tasks.

    These tokens must correspond to coordinates. A common practice is to normalize coordinates to a fixed grid (e.g., 0 to 1000), then discretize them into several coordinate tokens. During decoding, these are mapped back to the actual image size using the same grid. Therefore, simply checking the vocabulary file only proves that the model defines these tokens; it does not guarantee correct parsing during inference. You must also confirm that the same normalization rules are used during both training and inference.

    Visual primitive tokens must be mixed with standard text tokens within the same sequence. If the inference service does not enable the corresponding parsing logic, these tokens will be treated as plain text, causing the model to regress to natural language referencing.

    3. Comparison with Classic Visual Thinking

    The classic “thinking about images using natural language” approach relies entirely on text for reasoning, where the model completes tasks through description, comparison, and backtracking. The visual primitive approach inserts spatial tokens into the text reasoning. The differences are as follows:

    Dimension Visual Primitive Approach Classic Visual Thinking Approach
    Reference Method Point, box, polygon tokens Natural language descriptions
    Suitable Tasks Dense counting, precise localization, path planning Image Q&A, general description, common-sense reasoning
    Input Requirements Model must support visual primitive vocabulary and parsing A standard multimodal model suffices
    Output Verifiability Coordinates can be read directly for image comparison Requires manual judgment of description accuracy
    Typical Failure Mode Degrades to text when tokens are unparsed; coordinate misalignment Losing entities in long reasoning chains; duplicate or omitted counts

    Choosing the right approach depends on the task. If you only need to answer questions about image content, the classic approach is sufficient and easier to deploy. If the task relies on precise positions, the visual primitive approach is more suitable, but you must first verify that the service actually parses these tokens.

    4. Troubleshooting Inconsistencies Between Web and Open-Source Weights

    The same model may perform differently across open-source weights, web interfaces, and third-party agent frameworks. Possible reasons include: the vocabulary file not being loaded correctly; coordinate tokens being treated as plain text; inconsistent inference parameters between the server and open-source versions; or the frontend enabling different default image preprocessing.

    These causes can be verified through experimentation. Follow these steps:

    1. Fix the same test image, prompt, and temperature parameter (recommended to be set to 0), and run it three times in each environment.
    2. Save the model’s raw output and check whether coordinate tokens appear or if there are only natural language descriptions.
    3. If there are no coordinate tokens in the output, check the server logs to confirm whether the visual primitive parsing feature is enabled.
    4. Calculate accuracy using images with known answers (e.g., images with annotated headcounts) rather than looking at a single response.

    This article does not cite specific counting numbers from original materials. Without test images, prompts, model versions, and sampling parameters, such comparisons cannot be reproduced and should not be used as definitive conclusions.

    5. Configuration and Troubleshooting Checklist

    When configuring multimodal agents, many issues stem from the runtime environment rather than the model itself. Verify the following items before and after configuration:

    • Version: Run the tool’s built-in version command to confirm it meets the model documentation requirements. Use the specific commands and package names from the official documentation; do not blindly copy examples from unverified sources.
    • Permissions: Global installations typically require administrator privileges or user-level prefix configuration. Confirm the current user has write permissions before installing, and do not directly install packages from unknown sources as root.
    • Configuration Priority: Check command-line parameters first, then profiles, and finally configuration files. If both JSON files and command-line arguments are used, clarify which value takes effect and print the final configuration in the logs.
    • Separation of Model and Scheduling Settings: Model paths, vocabularies, and inference parameters belong to the model layer; timeouts, retries, and concurrency belong to the scheduling layer. Mixing them in a single JSON file can easily lead to mutual overwrites.
    • Parsing Verification: Enable debug logs to confirm that coordinate tokens appear in the output and that the decoded coordinates fall within the image boundaries.
    • Rollback: Back up original files before modifying configurations, and record old version numbers before upgrading so you can recover if issues arise.

    6. Applicable Scenarios and Recommendations

    The visual primitive approach is suitable for tasks requiring precise locations, such as dense counting, target localization, and path planning. It demands more from the inference service, so you should validate it with a small-scale test set before deployment.

    Recommendations:

    1. Build prototypes using the classic approach first. Switch only when counting or localization errors become prominent.
    2. Rerun a fixed test set after every model or tool version upgrade, and record accuracy changes.
    3. Include intermediate coordinate tokens in the logs. When errors occur, this helps determine whether the issue lies in perception, parsing, or reasoning.