{"record":{"id":"776a62a29738cc97","repo":"PaddlePaddle/PaddleOCR","slug":"you-cannot-specify-both-decoder-input-ids-and-deco-776a62","errorCode":null,"errorMessage":"You cannot specify both decoder_input_ids and decoder_inputs_embeds at the same time","messagePattern":"You cannot specify both decoder_input_ids and decoder_inputs_embeds at the same time","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"ppocr/modeling/heads/rec_unimernet_head.py","lineNumber":1038,"sourceCode":"    ):\n\n        output_attentions = (\n            output_attentions\n            if output_attentions is not None\n            else self.config.output_attentions\n        )\n        output_hidden_states = (\n            output_hidden_states\n            if output_hidden_states is not None\n            else self.config.output_hidden_states\n        )\n        use_cache = use_cache if use_cache is not None else self.config.use_cache\n        return_dict = (\n            return_dict if return_dict is not None else self.config.use_return_dict\n        )\n\n        if input_ids is not None and inputs_embeds is not None:\n            raise ValueError(\n                \"You cannot specify both decoder_input_ids and decoder_inputs_embeds at the same time\"\n            )\n        elif input_ids is not None:\n            input = input_ids\n            input_shape = input.shape\n            input_ids = input_ids.reshape([-1, input_shape[-1]])\n        elif inputs_embeds is not None:\n            input_shape = inputs_embeds.shape[:-1]\n            input = inputs_embeds[:, :, -1]\n        else:\n            raise ValueError(\n                \"You have to specify either decoder_input_ids or decoder_inputs_embeds\"\n            )\n\n        past_key_values_length = (\n            past_key_values[0][0].shape[2] if past_key_values is not None else 0\n        )\n","sourceCodeStart":1020,"sourceCodeEnd":1056,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/ppocr/modeling/heads/rec_unimernet_head.py#L1020-L1056","documentation":"The decoder in the UniMERNet head accepts token ids (decoder_input_ids) or continuous embeddings (decoder_inputs_embeds) as input, but not both at once, since it would be ambiguous which to embed. The forward method raises this ValueError immediately when both are non-None.","triggerScenarios":"Calling forward (directly or via generate) with both input_ids and inputs_embeds set; often happens when a wrapper pre-computes embeddings but still forwards the raw ids.","commonSituations":"Adapting generation code that supplies inputs_embeds for prompt conditioning while the model wrapper also forwards input_ids; copy-paste from a pipeline that fills all optional kwargs.","solutions":["Pass only input_ids and let the decoder embed them via embed_tokens","Or pass only inputs_embeds (pre-embedded inputs) and set input_ids=None"],"exampleFix":"# before\noutputs = decoder(input_ids=ids, inputs_embeds=embs)\n# after\noutputs = decoder(input_ids=ids)  # embeddings computed internally","handlingStrategy":"validation","validationCode":"assert not (input_ids is not None and inputs_embeds is not None), 'pass input_ids OR inputs_embeds, not both'","typeGuard":"def has_single_decoder_input(input_ids, inputs_embeds) -> bool:\n    return (input_ids is not None) ^ (inputs_embeds is not None)","tryCatchPattern":null,"preventionTips":["In wrappers, pass **filtered kwargs and delete inputs_embeds when ids are present","Treat input_ids/inputs_embeds as mutually exclusive in your call sites"],"tags":["paddle","decoder","mutually-exclusive-args","api-misuse"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}