{"record":{"id":"af4758eac4024dae","repo":"huggingface/transformers","slug":"inputs-inputs-were-passed-alongside-input-n","errorCode":null,"errorMessage":"`inputs`: {inputs}` were passed alongside {input_name} which is not allowed. Make sure to either pass {inputs} or {input_name}=...","messagePattern":"`inputs`: (.+?)` were passed alongside (.+?) which is not allowed\\. Make sure to either pass (.+?) or (.+?)=\\.\\.\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/transformers/generation/utils.py","lineNumber":670,"sourceCode":"        \"\"\"\n        This function extracts the model-specific `inputs` for generation.\n        \"\"\"\n        # 1. retrieve all kwargs that are non-None or non-model input related.\n        # some encoder-decoder models have different names for model and encoder\n        if (\n            self.config.is_encoder_decoder\n            and hasattr(self, \"encoder\")\n            and self.encoder.main_input_name != self.main_input_name\n        ):\n            input_name = self.encoder.main_input_name\n        else:\n            input_name = self.main_input_name\n\n        # 2. check whether model_input_name is passed as kwarg\n        # if yes and `inputs` is None use kwarg inputs\n        inputs_kwarg = model_kwargs.pop(input_name, None)\n        if inputs_kwarg is not None and inputs is not None:\n            raise ValueError(\n                f\"`inputs`: {inputs}` were passed alongside {input_name} which is not allowed. \"\n                f\"Make sure to either pass {inputs} or {input_name}=...\"\n            )\n        elif inputs_kwarg is not None:\n            inputs = inputs_kwarg\n\n        # 3. In the presence of `inputs_embeds` for text models:\n        # - decoder-only models should complain if the user attempts to pass `inputs_embeds`, but the model\n        # doesn't have its forwarding implemented. `inputs_embeds` is kept in `model_kwargs` and can coexist with\n        # input_ids (`inputs_embeds` will be used in the 1st generation step, as opposed to `input_ids`)\n        # - encoder-decoder models should complain if the user attempts to pass `inputs_embeds` and `input_ids`, and\n        # pull the former to inputs. It will be used in place of `input_ids` to get the encoder hidden states.\n        if input_name == \"input_ids\" and \"inputs_embeds\" in model_kwargs:\n            if model_kwargs[\"inputs_embeds\"] is None:\n                model_kwargs.pop(\"inputs_embeds\")\n            elif not self.config.is_encoder_decoder:\n                has_inputs_embeds_forwarding = \"inputs_embeds\" in set(\n                    inspect.signature(self.prepare_inputs_for_generation).parameters.keys()","sourceCodeStart":652,"sourceCodeEnd":688,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/generation/utils.py#L652-L688","documentation":"ValueError from GenerationMixin._prepare_model_inputs: you passed a positional `inputs` tensor AND the model's main input name (input_ids, or pixel_values etc. for multimodal) as a keyword argument in model_kwargs. The two routes for the same input are mutually exclusive; generate refuses to guess which one wins.","triggerScenarios":"model.generate(input_ids, input_ids=input_ids); multimodal: model.generate(pixel_values, pixel_values=pixel_values, input_ids=...); forwarding **inputs and also inputs['input_ids']=... explicitly; spreading a dict into generate() that already contains the main input name while also passing it positionally.","commonSituations":"Refactors that pass both a tensor and **model_kwargs; helper functions that accept inputs and then blindly merge a kwargs dict containing input_ids.","solutions":["Pass the tensor once — either positionally or as the keyword — and drop the other.","Audit the kwargs dict before generate: kwargs.pop(model.main_input_name, None) if you already pass it positionally.","For multimodal models, pass the non-text main input (e.g. pixel_values) as `inputs` and keep input_ids in kwargs."],"exampleFix":"# before\nout = model.generate(inputs.input_ids, **inputs)  # inputs already has input_ids\n\n# after\nout = model.generate(**inputs)","handlingStrategy":"validation","validationCode":"main_name = model.main_input_name\nif inputs is not None and main_name in model_kwargs:\n    model_kwargs.pop(main_name)  # keep the positional `inputs`\n# or: inputs = None","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never spread a dict into generate() while also passing its main key positionally.","Centralize input assembly in one function that returns either (inputs, kwargs) with no overlap.","Use generate(**tokenized) exclusively rather than mixing styles."],"tags":["generate","api-misuse","input-validation","multimodal"],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}