{"record":{"id":"25dd35b4b072db9c","repo":"docling-project/docling","slug":"expected-object-detection-model-metadata-to-expose-25dd35","errorCode":null,"errorMessage":"Expected object-detection model metadata to expose at least 3 outputs (labels, boxes, scores), got {len(metadata.outputs)}.","messagePattern":"Expected object-detection model metadata to expose at least 3 outputs \\(labels, boxes, scores\\), got (.+?)\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"docling/models/inference_engines/object_detection/api_kserve_v2_engine.py","lineNumber":85,"sourceCode":"            return self.options.model_name\n\n        return self._repo_id.replace(\"/\", \"--\")\n\n    def _resolve_model_version(self) -> Optional[str]:\n        return self.options.model_version\n\n    def _resolve_tensor_names(self) -> tuple[str, str, str, str, str]:\n        if self._kserve_client is None:\n            raise RuntimeError(\"KServe v2 client is not initialized.\")\n\n        metadata = self._kserve_client.get_model_metadata()\n        if len(metadata.inputs) < 2:\n            raise RuntimeError(\n                \"Expected object-detection model metadata to expose at least 2 inputs \"\n                f\"(images, orig_target_sizes), got {len(metadata.inputs)}.\"\n            )\n        if len(metadata.outputs) < 3:\n            raise RuntimeError(\n                \"Expected object-detection model metadata to expose at least 3 outputs \"\n                f\"(labels, boxes, scores), got {len(metadata.outputs)}.\"\n            )\n\n        input_images_name = metadata.inputs[0].name\n        input_orig_target_sizes_name = metadata.inputs[1].name\n        output_labels_name = metadata.outputs[0].name\n        output_boxes_name = metadata.outputs[1].name\n        output_scores_name = metadata.outputs[2].name\n\n        return (\n            input_images_name,\n            input_orig_target_sizes_name,\n            output_labels_name,\n            output_boxes_name,\n            output_scores_name,\n        )\n","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/docling-project/docling/blob/61d76f1ff3f8428065465889f7b4577da7df704c/docling/models/inference_engines/object_detection/api_kserve_v2_engine.py#L67-L103","documentation":"The KServe v2 engine requires the served model's metadata to expose at least 3 output tensors (labels, boxes, scores) in the DETR output convention. Fewer outputs means the served model is not a compatible object detector, and the engine raises RuntimeError rather than guessing which outputs to read.","triggerScenarios":"The KServe v2 endpoint's get_model_metadata() reports fewer than 3 outputs — e.g. a classifier returning a single logits tensor, or a detection model exported with fused/renamed outputs.","commonSituations":"Serving a model exported with the wrong ONNX opset/export config that collapsed outputs; pointing at the wrong model name on a multi-model server; version skew between the exported model and what the engine expects.","solutions":["Confirm the served model is an RT-DETR/DETR-family export producing labels, boxes and scores outputs; check with a raw KServe v2 metadata request.","Re-export the model with the standard 3-tensor detection head, or point options.model_name at the correct model.","Match the model revision configured on the server to the one Docling's model spec expects."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"meta = KserveV2Client(url=opts.url).get_model_metadata()\nassert len(meta.outputs) >= 3, f\"need labels/boxes/scores outputs, got {[o.name for o in meta.outputs]}\"","typeGuard":null,"tryCatchPattern":"try:\n    engine.initialize()\nexcept RuntimeError as e:\n    if \"at least 3 outputs\" in str(e):\n        raise RuntimeError(\"Served model is not a DETR-family detector; fix the KServe model repo\") from e\n    raise","preventionTips":["Validate server metadata (inputs>=2, outputs>=3) in deployment smoke tests.","Keep the served export and Docling's expected RT-DETR contract in sync.","Alert on server-side model redeployments that change the graph."],"tags":["kserve","model-mismatch","metadata","object-detection"],"backgroundTag":null,"analyzedSha":"61d76f1ff3f8428065465889f7b4577da7df704c","analyzedAt":"2026-08-14T23:53:18.727Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}