Visual Language Model Coordinate Representation and Grounding Capabilities

    This article explains why visual language models often show inconsistent object localization, and breaks the problem into two layers: whether the model has reliable spatial perception, and how coordinates are encoded and generated. It compares three coordinate representation schemes—relative coordinates with dedicated tokens, relative coordinates without dedicated tokens, and raw absolute coordinates—along with their token cost, sequence length, and convergence trade-offs. It then discusses end-to-end decoding versus external detectors and regression heads, prompt design for direct and example-guided grounding, structured JSON output conventions, and engineering safeguards for parsing, validation, and post-processing. Readers will learn why relative coordinates with dedicated tokens are favored and how prompt and output constraints determine whether the approach can be delivered reliably.

    1. Where the Problem Starts: Why Grounding Quality Keeps Fluctuating

    When visual language models are used for object localization, a commonly observed pattern is that different versions within the same model generation keep changing how they handle object coordinates: first relative coordinates, then absolute coordinates, and then relative coordinates again. This kind of back-and-forth is not arbitrary tinkering. It is the result of repeatedly trading off training stability, inference cost, and accuracy. To understand it, the problem needs to be split into two layers: one is whether the model has reliable spatial perception, and the other is in what form coordinates are expressed and generated.

    Traditional object detection and VLM-based grounding each have their own strengths. The former has a fixed structure and stable accuracy, but its category system and training distribution are relatively closed. The latter relies on large-scale image-text pretraining and offers open-vocabulary and instruction-following advantages, yet it often suffers from coordinate drift, duplicate boxes, and malformed output. One root cause of the difference is often not whether the model “understood the image,” but how coordinates are encoded into the language sequence.

    2. Three Coordinate Representation Schemes and Their Costs

    Coordinates are essentially numeric sequences, while language models operate on discrete token sequences. A mapping from numbers to tokens is therefore required first. Common industry practice falls into three categories.

    The first is relative coordinates with dedicated tokens. The x and y values are normalized by image width and height into a fixed integer range (for example, 0 to 999), and a pair of boundary tokens is added to the vocabulary to wrap the numbers. A box then needs only four tokens, keeping the sequence very short.

    The second is relative coordinates without dedicated tokens. The normalization step is the same, but during decoding the numbers are split into multiple sub-tokens, so a single box often expands to more than ten tokens.

    The third is raw absolute coordinates from the original image. The numeric range varies with resolution, and a box again requires more than ten tokens, with noticeable differences in value distribution across resolutions.

    The practical difference among the three can be expressed with a rough length estimate:

    1. def token_cost(n_boxes, per_box_tokens):
    2. # Fixed overhead from coordinate tokens and structural tokens
    3. return n_boxes * per_box_tokens + 8
    4. print(token_cost(10, 4)) # relative coordinates + dedicated tokens
    5. print(token_cost(10, 15)) # absolute coordinates or bare relative coordinates

    The difference in output is intuitive: for the same ten objects, the first approach uses about 48 tokens, while the second uses about 158. Tripling the sequence length means memory usage and attention computation during training and inference rise accordingly, and in long sequences the later coordinate tokens are more prone to being skipped or truncated. More importantly, absolute coordinates have a wide value range and inconsistent scale early in training, causing obvious loss fluctuation and unstable convergence. Once values are normalized into a fixed range, the distribution is compressed to a uniform scale, making it easier for the model to learn a stable mapping. This is the core reason the strategy swings back to relative coordinates.

    3. Choosing the Coordinate Output Path: End-to-End or Bolt-On

    After settling on the representation, the next decision is who generates the coordinates. There are three common paths: relying entirely on the model’s own language decoding ability to produce them directly; having an external detection model produce boxes first, then letting the language model filter and describe them; or adding a dedicated regression head on top of the language model to output numbers.

    Both the third and the second can improve numeric accuracy, but they break the end-to-end form. The bolt-on approach introduces cascading errors and engineering complexity, while the regression head requires extra label alignment and loss design and makes it hard to directly reuse the language model’s instruction-following ability. Since the goal is to give the model itself localization ability, coordinates should be part of the language output, using a unified sequence modeling approach to cover classification, localization, and referring tasks. The cost is that the approximate nature of numeric generation must be accepted, and the error must be pushed into an acceptable range through data construction and format constraints.

    4. Input Forms and Prompt Design

    In real applications, grounding requests usually fall into two categories, each needing its own prompt template.

    The first is direct grounding: given a category or description, output the positions of all matching objects in the image. The template emphasizes category constraints, uncertain object counts, and empty-result handling:

    1. Locate all objects matching "{target description}" in the image.
    2. Output a list where each element contains the label and the bounding box;
    3. if no matching object exists, output an empty list.

    The second is example-guided grounding: first mark a reference object in the image, then ask for other instances of the same kind. The template needs to explicitly introduce the reference ID so the model does not output the reference object again:

    1. The box labeled {reference ID} in the image is an example.
    2. Locate the remaining objects of the same kind in the image, and do not output that example again.
    3. Use the same output format as direct grounding.

    Three points matter in prompt design: constrain the output structure rather than only describing the task; specify how empty results are expressed to reduce hallucinated boxes; and give explicit rules for count and deduplication to lower the chance of duplicate predictions.

    5. Output Format Conventions and Engineering Implementation

    A structured text output is recommended at the output layer for easier parsing and validation:

    1. {
    2. "objects": [
    3. {"label": "object", "bbox": [120, 88, 340, 460]}
    4. ]
    5. }

    Three lines of defense are needed on the engineering side. The parsing layer should be fault-tolerant, tolerating extra whitespace and minor format deviations. The validation layer should check whether values fall within the agreed range, whether the left/right and top/bottom boundaries are ordered, and whether the area is zero. The post-processing layer should restore normalized coordinates to pixel coordinates using the original image width and height, then apply clipping and deduplication. For training data construction, coverage should span multiple resolutions, varying object counts, empty results, and referring scenarios, with random scaling and perturbation applied to coordinates to improve scale robustness.

    For large-scale deployment, container platforms can host training and inference workloads, object storage can manage image-text datasets, and logging and monitoring with alerts can track metrics such as parsing failure rate and out-of-range coordinate rate. Baidu AI Cloud provides standardized infrastructure support for these general capabilities, but the specific selection should still return to the accuracy and cost constraints of the task itself.

    6. Conclusion

    Behind the surface phenomenon of coordinate back-and-forth lies a three-way trade-off among sequence length, numeric distribution stability, and the end-to-end goal. Relative coordinates with dedicated tokens have clear advantages in length and convergence, end-to-end decoding preserves unified modeling ability, and the engineering constraints of prompts and output formats determine whether the whole approach can be delivered reliably. Understanding these three layers of trade-offs has more long-term value than memorizing the strategy choice of any single model generation.