Multimodal Visual Primitives: Technical Analysis and Practical Implementation

    This article explains why multimodal models often recognize subjects in images yet fail at dense counting, precise localization, and spatial reasoning. It breaks the problem into a perception gap and a reference gap, introduces visual primitives as structured, referenceable intermediate representations, and compares two technical routes: native visual primitives and "thinking with images." The article also outlines a multi-layer evaluation approach for verifying whether a system truly uses visual primitives, along with engineering guidance on input standardization, structured output, tool-chain decoupling, logging, and common pitfalls to avoid.

    1. Background: Why Multimodal Models “See but Cannot Explain”

    In real-world applications of multimodal large models, a common pattern appears: the model can identify the main subject in an image but performs inconsistently on tasks such as dense counting, fine-grained localization, and complex spatial reasoning. One typical case mentioned in the source material is that the same team photo produces different counting results through different interaction entry points; another case is that maze path planning differs between a paper’s description and web interaction. These phenomena do not necessarily mean the model’s capability has “disappeared.” More likely, they reflect differences in input presentation, reasoning chains, and output constraints, which cause result fluctuations.

    The industry usually splits this type of problem into two layers:

    1. Perception Gap: Factors such as image resolution, target scale, occlusion, and lighting lead to insufficient visual encoding, so the model “cannot see clearly.”
    2. Reference Gap: Even if the model sees the target clearly, if the reasoning process can only refer to “the second person on the left” or “the block near the edge” in natural language, the ambiguity of language itself amplifies uncertainty and causes multi-step reasoning to drift.

    Therefore, simply increasing resolution or enlarging model parameters does not always solve the problem. A more critical idea is to convert visual information into structured objects that the reasoning process can reference stably.

    2. Core Idea of Visual Primitives: Turning Images into Referenceable Structures

    “Visual primitives” can be understood as a visual intermediate representation designed for reasoning. They do not require the model to describe images only in natural language; instead, they introduce a set of constrained structured markers to represent geometric objects such as points, line segments, polygons, and bounding boxes. The special markers mentioned in the source material (such as open/close markers for points, polygons, and boxes) are exactly a manifestation of this idea: they act as “unambiguous pointers” in continuous visual space.

    The main advantages are:

    • Referenceability: Subsequent reasoning can directly reference the ID or handle of a structured object instead of relying on vague directional descriptions.
    • Composability: Complex targets can be expressed by combining points, boxes, and polygons, making it easier to represent hierarchy and containment relationships.
    • Verifiability: Structured output is easier for programs to parse, validate, and recompute, for example checking whether a box is out of bounds, whether a polygon is closed, or whether a count matches the object list.

    A schematic structured output can be expressed as:

    1. {
    2. "objects": [
    3. {"id": "p1", "type": "point", "x": 0.42, "y": 0.61},
    4. {"id": "b1", "type": "box", "x1": 0.30, "y1": 0.20, "x2": 0.55, "y2": 0.80},
    5. {"id": "g1", "type": "polygon", "points": [[0.1,0.1],[0.4,0.2],[0.3,0.5]]}
    6. ],
    7. "relations": [
    8. {"from": "p1", "to": "b1", "predicate": "inside"}
    9. ]
    10. }

    The value of this representation lies not in the format itself but in forming a closed loop of “look at the image, mark, reason, and answer.”

    3. Differences Between Two Technical Routes: Native Visual Primitives vs. “Thinking with Images”

    The source material points out that different product forms may adopt different routes: one natively supports visual-primitives-style processing inside the model; the other is closer to “Thinking with images,” where the model generates, modifies, and references images or markers on images during reasoning, then continues reasoning based on these intermediate artifacts.

    Neither route is absolutely superior. The differences are mainly in engineering constraints:

    Dimension Native Visual Primitives Route Thinking with Images Route
    Reasoning stability Strong structural constraints, clearer references Depends on intermediate image quality and tool calls
    Implementation complexity High training and data construction costs Relies more on agent frameworks and tool chains
    Explainability Structured objects can be audited directly Requires recording intermediate images and operation traces
    Applicable scenarios Dense counting, fine-grained localization Multi-step planning, interactive exploration

    From an engineering perspective, a more important concern is a “reproducible evaluation standard.” If a paper, web interaction, and an agent tool chain use different input scaling and different marker injection methods, result differences are normal. Therefore, when evaluating such capabilities, input resolution, preprocessing pipelines, prompt templates, and output parsing rules should be fixed.

    4. Evaluation and Reproduction: How to Tell Whether a Multimodal System Really Uses Visual Primitives

    The source material infers the technical route by checking special markers in the tokenizer. This is a feasible but insufficient clue. A more rigorous verification should include multiple layers of evidence:

    1. Interface-layer evidence: Whether the output contains parseable structured objects (points, boxes, polygons) rather than pure natural language.
    2. Behavior-layer evidence: In dense counting tasks, whether the model first generates an object list and then gives the total, and whether the total aligns with the list length.
    3. Consistency evidence: Whether structured objects and final answers remain stable across different entry points and random seeds for the same image.
    4. Ablation evidence: Whether performance drops significantly after removing structured markers or switching to pure text prompts.

    Reference evaluation pseudocode:

    1. def eval_count(image, run_model):
    2. out = run_model(image, prompt="Please output a structured object list and count")
    3. objs = parse_objects(out) # Parse points/boxes/polygons
    4. count = len(objs)
    5. consistency = check_ids_unique(objs)
    6. return {"count": count, "valid": consistency, "raw": out}

    Only when structured output, counting logic, and consistency checks all hold can one be fairly confident that the system uses a visual-primitives-style intermediate representation.

    5. Engineering Implementation: Integrating Visual Primitives into Business Systems

    To apply this idea in your own application, start from three principles: “observable, rollback-capable, and auditable.”

    • Input standardization: Unify scaling strategies and coordinate normalization to avoid different visual contexts from different entry points.
    • Structured output: Require the model to return constrained structured objects, validate the schema on the server side, and retry or degrade on failure.
    • Tool-chain decoupling: Make image processing, marker drawing, and object parsing independent services for easier model replacement and canary releases.
    • Full-chain logging: Record original image digests, intermediate marker images, structured objects, and final answers to support incident review.
    • General cloud capabilities: You can combine object storage to save intermediate artifacts, message queues for peak shaving, container platforms to host inference services, and logging and monitoring with alerting to track success rates and latency.

    A simplified server-side validation example:

    1. def validate(out):
    2. if not out.get("objects"):
    3. return False, "Missing structured objects"
    4. ids = [o["id"] for o in out["objects"]]
    5. if len(ids) != len(set(ids)):
    6. return False, "Duplicate object IDs"
    7. return True, "ok"

    6. Common Pitfalls and Best Practices

    • Pitfall 1: Attributing all counting errors to the model. Many times it is inconsistent preprocessing and prompts. The best practice is to fix the evaluation standard and publish intermediate artifacts.
    • Pitfall 2: Assuming more special markers are always better. Marker design must match the target task; excessive complexity increases parsing failure rates.
    • Pitfall 3: Ignoring coordinate systems. Mixing pixel coordinates and normalized coordinates is a common cause of localization drift and should be clearly specified at the interface layer.
    • Pitfall 4: Only doing end-to-end black-box testing. Add structure-level unit tests, such as polygon closure, non-zero box area, and points falling within image bounds.

    7. Conclusion

    The essence of visual primitives is upgrading “looking at images and speaking” to “looking at images, marking, and then reasoning.” It alleviates the reference gap through structured pointers, making dense counting, complex localization, and multi-step planning more verifiable. For developers, the truly reusable experience is not chasing a specific product form but establishing standardized inputs, structured outputs, recomputable evaluations, and observable engineering pipelines. Whoever is rigorous in these areas will achieve more stable results and lower maintenance costs in multimodal applications.