Structured Visual Primitive Tokens: Format Design, Parsing, and Deployment Risks

    Structured visual primitive tokens let multimodal models emit points, boxes, and polygons as part of a token sequence that programs can parse directly, reducing the need for separate detection or segmentation heads. This article covers coordinate tokenization methods, point/box/polygon format conventions, reference tags, constrained decoding, use cases, failure modes, evaluation steps, and a pre-integration checklist.

    The Short Answer

    Structured visual markers allow a model to write points, boxes, and polygons into a token sequence as part of its text output. A program can read these sequences directly, eliminating the need for an additional detection head or segmentation head. However, the effectiveness of this approach depends on the coordinate representation, the training data, and the parsing rules. Before choosing an approach, validate it on your own data.

    What Are Visual Primitive Tokens?

    Traditional vision-language models usually use a visual encoder to convert an image into continuous features, which are then fused with text. This approach is end-to-end differentiable, but it is difficult to directly output a closed region coordinate. The visual primitive approach designs dedicated tokens for geometric elements. While generating text, the model can output the position of a box in the same sequence without calling a separate detection module.

    There are three common primitive types: points, boxes, and polygons. There is also a reference marker type, used to associate later text with a primitive output earlier in the same response. The specific token names and numbering are defined by each model. Before use, consult the model’s tokenizer files and official documentation.

    How Coordinates Become Tokens

    A model needs to turn numbers into tokens. There are three common methods.

    The first is digit-by-digit tokenization. A coordinate such as 0.32 is split into several digit tokens and a decimal point. This is simple to implement, but the same value occupies multiple positions, making the sequence longer.

    The second is binning. The normalized range from 0 to 1 is divided into a fixed number of intervals, for example 1,000, and each interval corresponds to a dedicated token. Precision is determined by the number of intervals. More intervals mean finer localization but a larger vocabulary.

    The third is continuous embeddings. The model does not generate numbers directly; instead, it outputs a vector, which a dedicated head decodes into coordinates. This method offers higher precision, but it requires changes to the decoding structure and is not fully consistent with the standard language model interface.

    Whichever method is used, the documentation should clearly state the normalization range (usually 0 to 1 relative to image width and height, or a 0 to 999 integer grid), the number of decimal places retained, and the separators.

    Format Conventions for Points, Boxes, and Polygons

    A parseable format should contain three parts: a start marker, coordinate content, and an end marker. The following formats are illustrative and are not the actual output of any specific model.

    Point: a start marker followed by [x, y], then an end marker. For example, a format for representing a key point is <|point|>[0.32, 0.45]<|/point|>.

    Box: use [x1, y1, x2, y2] to represent the top-left and bottom-right corners. Require x1 to be less than x2 and y1 to be less than y2. If this constraint is violated, the parser should treat the box as invalid.

    Polygon: list the vertices in order, for example <|polygon|>[[0.10, 0.20], [0.40, 0.22], [0.38, 0.61]]<|/polygon|>. Set a maximum number of vertices and require at least three vertices.

    During parsing, the program should first match the start and end markers, then check the number of values and the numeric range. If any step fails, it should log the error and discard the primitive rather than guessing and completing it.

    How to Use Reference Tags

    Reference tags establish a correspondence between text and primitives. The following is an illustrative convention: inside a reference block, write a label and include the primitive number. Numbering starts at 1 and follows the order in which primitives appear in the current response.

    A complete example follows. The model first outputs a box:

    1. <|box|>[0.12, 0.30, 0.55, 0.68]<|/box|>

    It then references that box in the body text:

    1. <|ref|>Invoice number #1<|/ref|> is located in the upper right and consists of eight digits.

    Here, #1 points to the first box in the current response. The rules can be defined as follows: a reference may only point to a primitive that has already appeared in the same response; the reference scope is limited to the current response and does not cross turns; when a reference points to a nonexistent primitive, the parser should mark it as a dangling reference and let the caller decide whether to discard or retry.

    These rules need to be enforced by the consumer’s parsing program. The model itself may not guarantee valid references, so the proportion of dangling references should be measured before launch.

    Constrained Generation and Visual Grammar

    Some people call this capability visual grammar, but that term can be misleading. A more accurate description is that the model has learned a formatting habit during training, for example, that a start marker is usually followed by numbers.

    To make the format stable, a common technique is constrained decoding. It blocks tokens that violate the grammar during generation, such as allowing only digits and commas at coordinate positions. Constrained decoding can guarantee that the output format is valid, but it does not guarantee accurate localization. Format correctness and localization correctness are two separate problems and should be evaluated separately.

    Suitable Use Cases

    Structured markers are suitable for outputs that need to be consumed by programs. Typical scenarios include the following.

    Document parsing: the positions of signature areas, stamp regions, and table cells can be written directly into structured data.

    UI automation: the model outputs the center point of a button, and an automation script performs the click. Before clicking, verify whether the coordinate falls within an interactive area.

    Industrial inspection: output a polygon of a defect contour for downstream judgment of whether it exceeds tolerance. If polygon precision is insufficient, the decision result will be distorted, so error should be measured using labeled samples.

    The common factor in these scenarios is that the output has a clear consumer. If the output is only meant for people to read, ordinary text descriptions are usually simpler.

    Comparison with Traditional Approaches

    The following table lists comparison dimensions, not measured values. Specific gaps need to be measured on your own data.

    Dimension Encoder plus text decoding Visual primitive tokens
    Output form Text; coordinates require secondary parsing Structured tokens; directly parseable
    Extra modules Often requires a detection head or segmentation head Usually not required
    Sequence length Shorter Noticeably longer when a polygon has many vertices
    Localization accuracy Depends on encoder and training data Depends on coordinate representation
    Failure form Text errors, harder to detect automatically Format errors can be detected automatically; localization deviation requires evaluation
    Training requirements Loss depends on task design Requires labeled data containing coordinates

    In terms of cost, long sequences increase inference latency and expense. If a polygon has 50 vertices and each vertex has two coordinates, the output length increases significantly. The context window is also occupied, reducing capacity for other content in the same request.

    Common Failure Modes

    In practice, several problems are common.

    Format errors: a missing end marker, or an incorrect number of coordinates. Validate at the parsing layer and set up retries.

    Numeric drift: coordinates are valid at the numeric level but deviate significantly from the true position. This type of problem can only be found through an evaluation set.

    Occlusion and ambiguous boundaries: when the target is partially visible, the model may output unstable boxes, and results for the same image may differ between two requests.

    Too many vertices: the polygon vertex count exceeds the limit, causing output truncation. A truncated polygon may self-intersect, so detection should be performed during parsing.

    How to Evaluate Whether to Adopt It

    Before adoption, consider validating with the following steps.

    First, prepare a small evaluation set containing real annotations, covering normal samples, occluded samples, and boundary samples.

    Second, measure the format validity rate, localization metrics such as box IoU, and the dangling reference ratio separately.

    Third, record end-to-end latency and per-request cost, and compare them with the existing approach.

    Fourth, define a fallback strategy. For example, when parsing fails, reprocess with a traditional detection model and log the sample.

    Only when these metrics are within an acceptable business range is it worth replacing the existing process.

    Pre-Integration Checklist

    Before integration, confirm the following: the input image resolution and preprocessing method; the coordinate normalization range and precision; the output schema and version number; the parser’s rules for handling format errors, out-of-bounds values, and dangling references; whether raw output is saved in logs for troubleshooting; and whether a human review step is included.

    Data security also needs to be considered. Images may contain personal information such as identity documents or contracts, and both transmission and storage should meet the relevant compliance requirements.

    Conclusion

    Structured visual markers provide a more direct output method for multimodal models, especially in scenarios where visual results need to be handed to programs for processing. Their value comes from a clear format and verifiable output. Before adoption, developers should measure format validity rate, localization accuracy, and cost on their own data. Whether this type of approach will be widely adopted depends on the maturity of the model ecosystem, public evaluation standards, and engineering tools, and this remains to be seen.