{"record":{"id":"8a5d86c30871d9d8","repo":"roboflow/supervision","slug":"number-of-ref-tags-len-label-segments-and-det","errorCode":null,"errorMessage":"Number of ref tags ({len(label_segments)}) and det tags ({len(detection_segments)}) in the result must be equal.","messagePattern":"Number of ref tags \\((.+?)\\) and det tags \\((.+?)\\) in the result must be equal\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/detection/vlm.py","lineNumber":466,"sourceCode":"        resolution_wh: Tuple (width, height) to which we scale the box coordinates.\n        classes: Optional list of valid class names. If provided, boxes and labels not\n            in this list are filtered out.\n\n    Returns:\n        A tuple of `(xyxy, class_id, class_name)` where `xyxy` is an array of\n            shape `(n, 4)` in format `[x1, y1, x2, y2]`, `class_id` is an\n            optional array of shape `(n,)` with class indices, and `class_name`\n            is an array of shape `(n,)` with class labels. When the input\n            contains no detections (or all are filtered by `classes`), returns\n            `(np.empty((0, 4)), np.empty(0), np.empty(0))`.\n    \"\"\"  # noqa: E501\n\n    width, height = resolution_wh\n    label_segments = re.findall(r\"<\\|ref\\|>(.*?)<\\|/ref\\|>\", result, flags=re.S)\n    detection_segments = re.findall(r\"<\\|det\\|>(.*?)<\\|/det\\|>\", result, flags=re.S)\n\n    if len(label_segments) != len(detection_segments):\n        raise ValueError(\n            f\"Number of ref tags ({len(label_segments)}) \"\n            f\"and det tags ({len(detection_segments)}) in the result must be equal.\"\n        )\n\n    xyxy_list: list[list[float]] = []\n    class_name_list: list[str] = []\n    for label, detection_blob in zip(label_segments, detection_segments):\n        current_class_name = label.strip()\n        for box in re.findall(r\"\\[(.*?)\\]\", detection_blob):\n            x1, y1, x2, y2 = map(float, box.strip(\"[]\").split(\",\"))\n            xyxy_list.append(\n                [\n                    (x1 / 999 * width),\n                    (y1 / 999 * height),\n                    (x2 / 999 * width),\n                    (y2 / 999 * height),\n                ]\n            )","sourceCodeStart":448,"sourceCodeEnd":484,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/detection/vlm.py#L448-L484","documentation":"Error \"Number of ref tags ({len(label_segments)}) and det tags ({len(detection_segments)}) in the result must be equal.\" thrown in roboflow/supervision.","triggerScenarios":"Thrown at src/supervision/detection/vlm.py:466 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the model output contains an equal number of <ref> and <det> tag pairs; regenerate or repair the prompt/response.","If parsing a custom output, align each reference label segment with exactly one detection segment before calling the parser."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7f254d9784d4c37e0f03cd89ddee164c8db099c0","analyzedAt":"2026-08-15T05:13:01.950Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}