Document, Diagram, and Interface Understanding › Grounding: Regions, Coordinates, and Actions
Language AI HandbookAll chapters Grounding connects a prediction to a region or an element. A referring expression may request one region, a question may need evidence from several regions, and an action instruction refers to an element with a present state. SeeClick studies screenshot-only GUI grounding and introduces ScreenSpot, a benchmark for grounding language instructions to interface elements. That is distinct from measuring whether an interaction brings about the requested state after a click.
If a structured interface supplies labels and stable element identifiers, a harness can score a target match against those labels. Give it the interface revision, visible bounds and current state, because a stale identifier could refer to a different control or point. If you use coordinates instead, state whether they are image pixels, scaled CSS coordinates or normalized coordinates, and check their mapping at the moment of the action. A screenshot alone does not reveal all possible state. In particular, matching the word "Dark theme" does not determine whether enabling it requires a click.
Our fixture supplies typed elements and pixel bounds for a hypothetical 1024-by-640 viewport. The code reads only this structured metadata. A matcher compares normalized labels and abstains on ambiguity. Once it chooses the toggle, a second step checks whether the desired state is already present. The code returns a proposed point, never a live UI operation.
PythonIn [24]Expand
controls = [
{
"id": "dark-theme",
"label": "Dark theme",
"role": "toggle",
"checked": False,
"box": (752, 150, 790, 175),
},
{
"id": "auto-update",
"label": "Auto-update",
"role": "toggle",
"checked": True,
"box": (752, 200, 790, 225),
},
]
def choose_toggle(elements, label, desired):
matches = [
item
for item in elements
if item["role"] == "toggle"
and item["label"].casefold() == label.casefold()
]
if len(matches) != 1:
return {"status": "ambiguous-or-absent"}
item = matches[0]
if item["checked"] == desired:
return {"status": "already-set", "id": item["id"]}
x0, y0, x1, y1 = item["box"]
return {
"status": "proposed",
"id": item["id"],
"point": ((x0 + x1) / 2, (y0 + y1) / 2),
}
proposal = choose_toggle(controls, "dark theme", True)
already_set = choose_toggle(controls, "auto-update", True)
duplicate = controls + [dict(controls[0], id="other-dark-theme")]
ambiguous = choose_toggle(duplicate, "dark theme", True)ConsoleOut [25]Expand
Change needed: {'status': 'proposed', 'id': 'dark-theme', 'point': (771.0, 162.5)}
No action needed: {'status': 'already-set', 'id': 'auto-update'}
Duplicate label: {'status': 'ambiguous-or-absent'}The true element is the same for both a point-in-region test and an identifier test on this record, but the metrics need not agree. A visible icon may occupy part of a button while its full hit area is larger. For a workflow evaluation, also test whether the intended control changed state and whether unrelated controls kept theirs. Re-evaluating the current state after a redraw checks a different failure than locating the control in an old screenshot. A local fixture can support repeatable tests for duplicate labels or clipped bounds without instrumenting a user’s private screen.
Rechecking an old coordinate after a viewport change
Keep the previous target identifier and generate a second hypothetical viewport at half the original scale. This is an affine coordinate exercise from typed data. It uses the same element boxes and the same proposed point already inspected above, and computes where the point would need to be in the new view.
PythonIn [26]Expand
viewport_scale = 0.5
def scale_edges(values, scale):
return tuple(scale * value for value in values)
def point_in_box(point, box):
x, y = point
x0, y0, x1, y1 = box
return x0 <= x <= x1 and y0 <= y <= y1
target_control = next(item for item in controls if item["id"] == proposal["id"])
scaled_controls = [
{**item, "box": scale_edges(item["box"], viewport_scale)}
for item in controls
]
same_target = next(
item for item in scaled_controls if item["id"] == proposal["id"]
)
scaled_point = scale_edges(proposal["point"], viewport_scale)
assert point_in_box(proposal["point"], target_control["box"])
assert not point_in_box(proposal["point"], same_target["box"])
assert point_in_box(scaled_point, same_target["box"])ConsoleOut [27]Expand
Old point (771.0, 162.5); scaled point (385.5, 81.25). Old point matches the scaled target: False Mapped point matches the same target: True
VisualizationOut [28]Expand

The boxes and points have the same relative placement in both panels. Pixel numbers differ because the frames have different scales. The old point fails the same-target box test, and the mapped half-scale point passes it. This preserves the distinction between recognizing the correct element and having a suitable coordinate for the current viewport. A stale point from a previous layout would need an actual new localization when a simple scale transform no longer describes the change.
Keep screen points attached to the right revision
An interface grounding result can return a coordinate, an element identifier or both. A coordinate refers to a particular image and its coordinate system. An identifier refers to an element in a particular interface representation. An accessible or structured tree may place an outer hit region around a small visible glyph, so object detection and an effective click region can differ. If the viewport or scale changes, a new point may be needed even if the stable identifier still refers to the same control. If components are regenerated, an identifier can become stale even when the pixels look unchanged.
A point answer should carry enough information to map it back to the view that generated the prediction. One can test this on a static layout using a coordinate transform. If an entire drawing is uniformly scaled to half its original width and height about the origin, matching the new view requires halving the original pixel coordinates and all its box corners. If a content crop then removes a margin, subtract the crop origin in the scaled frame before comparing a point with boxes in crop coordinates. The order of these operations matters when the crop offset is specified in a different frame. Named coordinate frames and a concrete witness make these transforms easier to audit.
Document grounding and interface grounding share a need to attach predictions to evidence, but the latter can also need current state. A request to set a toggle on has a different success condition from a request to invert it. If it is already on, a correct system may return “already set” instead of proposing a click. Receiving a point in the intended control region does not by itself demonstrate the requested state was achieved. A combined evaluator can record target selection, precondition, proposed transition and verified resulting state under a safe, authorized interaction protocol. In this notebook the proposal remains a record in a local fixture. The static mock can test current state and identity without causing a side effect.
A repeated label is useful for evaluating abstention. If the same label appears in several settings sections, choosing the first result can be wrong even if its role is a toggle. Additional structure such as the section name or stable identifier may resolve the ambiguity, but only when it is present and within scope. The simple resolver has no such extra context; it reports ambiguity or absence when the matching criterion selects other than exactly one element. Real evaluation should capture which cue justified a proposed disambiguation before counting it as an interface success.
Evidence for question answering
An answer that includes a bounding box can be audited at the evidence level. If the text is correct but points at a subtotal rather than the taxed total, the stated provenance is wrong. If a region is correct but the recognizer returns a malformed string, localization succeeded while transcription failed. A broad region may contain both the desired and misleading values. A geometric threshold can score whether it sufficiently overlaps the available reference region, but evidence quality for the task can depend on whether the relevant text actually appears and is specific enough to justify the answer.
Consider reporting a page index, field identity, raw value and transformed coordinates as one result, then aggregating over fields. A document with two copies of the same number should not let a region match the item solely by text equality. Similarly, evaluation of a chart extraction can match the category and axis before comparing the numeric value. This use of identity distinguishes correct association from coincidence. A text retrieval pipeline can store short evidence spans alongside each answer for a human check, while a benchmark can score automated associations against a trusted reference.
An audit can include a controlled missing-evidence example. Remove or corrupt one field while retaining the rest of the document and ask for both the now-unavailable field and an unaffected adjacent one. An ideal diagnostic can distinguish the predicted missing field, an unavailable verification step and a correct neighboring answer. This chapter's invoice contains a text-layer corruption at one field while keeping its raster evidence and physical coordinates unchanged. It shows how a pipeline can expose an error instead of filling in a plausible substitute. The model would need additional evidence to recover a correct transcription from the pixels.
Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!