Multimodal Large Model Visual Primitives: How Structured Vision Output Works

    This article breaks down the visual primitive mechanism used in multimodal large models, where paired special tokens wrap points, polygons, bounding boxes, and references so geometry can be generated like text. It covers the design rationale, tokenizer and quantization details, alignment with the vision encoder, a decoding state machine, data construction and evaluation practices, common pitfalls, and engineering rollout advice.

    1. Background: Where Multimodal Fusion Actually Breaks Down

    Most experimental multimodal models of the past two years still follow the same basic stack: a vision encoder, a projection layer, and a language model. The route is mature from an engineering standpoint, but it shows three persistent pain points when structured visual information is involved.

    The first is loss of spatial precision. Splitting an image into fixed-grid patches and compressing them into a small set of vectors is effectively a lossy sampling of spatial information. High-frequency details such as small objects, dense text, and thin strands of hair tend to be smoothed away as the compression ratio increases.

    The second is the difficulty of binding instructions to visual entities. When a user says “mark the second box from the left in red,” the model has to map the referring expression in language onto image coordinates reliably. If coordinates are just sequences of floating-point numbers, the model has no explicit structural prior, and the stability of reference resolution drops noticeably.

    The third is uncontrolled output format. When a model is asked to emit coordinates directly, value drift, missing points, and broken closure relationships occur frequently, so downstream parsing code ends up carrying a large amount of fault-tolerant logic.

    The core idea of the visual primitive route is to abstract all of the above into a sequence modeling problem: define a set of discrete tokens for visual structures, and let the model generate geometry the same way it generates text.

    2. Design Logic Behind Visual Primitives

    A common practice is observable in public model configuration files: an additional set of paired special tokens is registered in the vocabulary to wrap points, polygons, bounding boxes, and reference relations. The semantics are roughly as follows.

    • Point token pair: wraps a group of coordinates, representing keypoints, center points, or annotation anchors.
    • Polygon token pair: wraps a closed sequence of vertices, suitable for approximating segmentation masks.
    • Bounding box token pair: wraps the top-left and bottom-right corners, used for detection and localization.
    • Reference token pair: wraps the identifier of the referenced target, used to establish coreference and association.

    A schematic vocabulary structure looks like this (it only expresses the design pattern, not a specific implementation):

    1. [
    2. {"id": 129271, "content": "<|/polygon|>", "special": true},
    3. {"id": 129272, "content": "<|polygon|>", "special": true},
    4. {"id": 129273, "content": "<|/point|>", "special": true},
    5. {"id": 129274, "content": "<|point|>", "special": true},
    6. {"id": 129275, "content": "<|/box|>", "special": true},
    7. {"id": 129276, "content": "<|box|>", "special": true},
    8. {"id": 129277, "content": "<|/ref|>", "special": true},
    9. {"id": 129278, "content": "<|ref|>", "special": true}
    10. ]

    Three engineering details here are easy to overlook.

    First, the tokens must be declared as indivisible atomic units. If the tokenizer splits a token into multiple subwords, what the model learns is not structural semantics but string fragments, and the bracket-pairing rate during generation degrades significantly.

    Second, the tokens need to come in pairs with strict nesting. Opening and closing tokens form a natural formal grammar constraint, which allows a hard check with a state machine at decoding time; illegal sequences can be rejected and resampled directly.

    Third, coordinate quantization has to work together with the tokens. A common industry practice is to discretize normalized coordinates into a fixed range (for example, integers from 0 to 1000) expressed with ordinary numeric tokens, reusing the numerical generation ability the language model already has and avoiding vocabulary expansion for every coordinate value, which would inflate the parameter count.

    3. Connecting to the Vision Encoder

    Visual primitives only become meaningful once they are aligned with the representation on the vision side, which usually requires coordination in three places.

    On the input side, the image passes through the vision encoder to produce a sequence of patch features, which the projection layer maps into the language model’s embedding space. To let the model know where a “coordinate” points, training generally establishes a learnable attention association between coordinate tokens in the text and image features, rather than stitching them together with hand-written rules.

    On the output side, the model autoregressively generates a sequence containing primitive tokens. The decoder needs to maintain a lightweight state machine that tracks which primitive it is currently inside, how many coordinates have been collected, and whether a polygon has been closed.

    1. # Schematic of the primitive state machine at decoding time
    2. PRIMITIVES = {"<|box|>", "<|polygon|>", "<|point|>", "<|ref|>"}
    3. CLOSERS = {"<|box|>": "<|/box|>", "<|polygon|>": "<|/polygon|>",
    4. "<|point|>": "<|/point|>", "<|ref|>": "<|/ref|>"}
    5. def step(state, token):
    6. if token in PRIMITIVES:
    7. state.stack.append((token, []))
    8. elif state.stack and token == CLOSERS[state.stack[-1][0]]:
    9. kind, payload = state.stack.pop()
    10. state.done.append((kind, normalize(payload)))
    11. elif state.stack:
    12. state.stack[-1][1].append(token)
    13. return state

    What needs emphasis is that the state machine validates and reshapes output; it does not replace model capability. If the model has not learned the structural constraints, forced patching only produces geometry that looks valid but is semantically wrong.

    4. Training and Data Construction

    Data quality sets the ceiling on primitive capability. Four construction principles are relatively reliable in practice.

    First, mixed supervision. Blend five sample types in a controlled ratio: plain text, image-text question answering, localization, segmentation, and coreference, so the model does not lose language ability after visual tasks are added.

    Second, coordinate consistency checks. Before data is stored, all annotations undergo unified normalization and range clipping, and out-of-bounds or degenerate polygons (zero area, duplicated vertices) are removed.

    Third, difficulty stratification. Sample in buckets by object scale, occlusion ratio, and vertex count to prevent the training distribution from being dominated by a large number of easy samples.

    Fourth, negative sample design. Build samples such as “the referenced object does not exist” or “output a category that is not present,” to suppress hallucinated coordinate generation.

    5. Evaluation and Common Pitfalls

    Evaluation should cover at least three dimensions: geometric accuracy (such as intersection over union and point offset distance), format validity (bracket pairing and coordinate range), and instruction following (whether coreference and attribute modification hit the target).

    There are three common pitfalls. One is looking only at overall intersection over union while ignoring the small-object subset, which makes conclusions overly optimistic. The second is treating format validity as an effectiveness metric; valid does not mean correct. The third is measuring multimodal capability with a general text evaluation set, which hides weaknesses in spatial understanding.

    6. Engineering Rollout Advice

    To reuse this route in your own business, the suggested order is: first clarify whether the task needs explicit geometric output, then decide the coordinate quantization granularity and the primitive set, then build a decoding pipeline with hard validation, and finally set up a bucketed evaluation set for continuous regression. On the infrastructure side, training samples and annotations can be stored in object storage, job scheduling can be handled by a container platform, and pipeline quality can be observed continuously through logging services and monitoring alerts. If you want to lower the cost of building everything yourself, you can also evaluate the general model services and data processing capabilities offered by Baidu AI Cloud, and focus your effort on the data and evaluation system.

    In summary, the value of visual primitives lies not in the tokens themselves but in upgrading “look at an image and talk about it” to “look at an image and point at things precisely,” extending multimodal output from natural language to executable structured results.