{"record":{"id":"10168daf3ea24b37","repo":"run-llama/llama_index","slug":"structured-prediction-failed-for-nodes-idx-id","errorCode":null,"errorMessage":"Structured prediction failed for nodes {idx} - {idx + self.choice_batch_size}: {result}","messagePattern":"Structured prediction failed for nodes (.+?) - (.+?): (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/postprocessor/structured_llm_rerank.py","lineNumber":189,"sourceCode":"        ) as event:\n            for idx in range(0, len(nodes), self.choice_batch_size):\n                nodes_batch = [\n                    node.node for node in nodes[idx : idx + self.choice_batch_size]\n                ]\n\n                query_str = query_bundle.query_str\n                fmt_batch_str = self._format_node_batch_fn(nodes_batch)\n                # call each batch independently\n                result: Union[BaseModel, str] = self.llm.structured_predict(\n                    output_cls=self._document_relevance_list_cls,\n                    prompt=self.choice_select_prompt,\n                    context_str=fmt_batch_str,\n                    query_str=query_str,\n                )\n                # in case structured prediction fails, a str of the raised exception is returned\n                if isinstance(result, str):\n                    if self._raise_on_structured_prediction_failure:\n                        raise ValueError(\n                            f\"Structured prediction failed for nodes {idx} - {idx + self.choice_batch_size}: {result}\"\n                        )\n                    logger.warning(\n                        f\"Structured prediction failed for nodes {idx} - {idx + self.choice_batch_size}: {result}\"\n                    )\n                    # add all nodes with score 0\n                    initial_results.extend(\n                        [NodeWithScore(node=node, score=0.0) for node in nodes_batch]\n                    )\n                    continue\n\n                raw_choices, relevances = self._parse_choice_select_answer_fn(\n                    result, len(nodes_batch)\n                )\n                choice_idxs = [int(choice) - 1 for choice in raw_choices]\n                choice_nodes = [nodes_batch[idx] for idx in choice_idxs]\n                relevances = relevances or [1.0 for _ in choice_nodes]\n                initial_results.extend(","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/postprocessor/structured_llm_rerank.py#L171-L207","documentation":"Error \"Structured prediction failed for nodes {idx} - {idx + self.choice_batch_size}: {result}\" thrown in run-llama/llama_index.","triggerScenarios":"Thrown at llama-index-core/llama_index/core/postprocessor/structured_llm_rerank.py:189 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the LLM structured output for the failing batch; retry with a model that supports structured output.","Reduce choice_batch_size so each structured prediction is simpler."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}