{"record":{"id":"07e59ec3bbbaf451","repo":"lllyasviel/Fooocus","slug":"you-cannot-specify-both-input-ids-and-inputs-embed-07e59e","errorCode":null,"errorMessage":"You cannot specify both input_ids and inputs_embeds at the same time","messagePattern":"You cannot specify both input_ids and inputs_embeds at the same time","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"extras/BLIP/models/nlvr_encoder.py","lineNumber":753,"sourceCode":"            (those that don't have their past key value states given to this model) of shape :obj:`(batch_size, 1)`\n            instead of all :obj:`decoder_input_ids` of shape :obj:`(batch_size, sequence_length)`.\n        use_cache (:obj:`bool`, `optional`):\n            If set to :obj:`True`, :obj:`past_key_values` key value states are returned and can be used to speed up\n            decoding (see :obj:`past_key_values`).\n        \"\"\"\n        output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions\n        output_hidden_states = (\n            output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states\n        )\n        return_dict = return_dict if return_dict is not None else self.config.use_return_dict\n\n        if is_decoder:\n            use_cache = use_cache if use_cache is not None else self.config.use_cache\n        else:\n            use_cache = False\n\n        if input_ids is not None and inputs_embeds is not None:\n            raise ValueError(\"You cannot specify both input_ids and inputs_embeds at the same time\")\n        elif input_ids is not None:\n            input_shape = input_ids.size()\n            batch_size, seq_length = input_shape\n            device = input_ids.device\n        elif inputs_embeds is not None:\n            input_shape = inputs_embeds.size()[:-1]\n            batch_size, seq_length = input_shape\n            device = inputs_embeds.device\n        elif encoder_embeds is not None:    \n            input_shape = encoder_embeds.size()[:-1]\n            batch_size, seq_length = input_shape \n            device = encoder_embeds.device\n        else:\n            raise ValueError(\"You have to specify either input_ids or inputs_embeds or encoder_embeds\")\n\n        # past_key_values_length\n        past_key_values_length = past_key_values[0][0].shape[2] if past_key_values is not None else 0\n","sourceCodeStart":735,"sourceCodeEnd":771,"githubUrl":"https://github.com/lllyasviel/Fooocus/blob/ae05379cc97bc4361ec8b4ec90193dab21be763f/extras/BLIP/models/nlvr_encoder.py#L735-L771","documentation":"NLVR encoder's BertModel forward rejects calls that provide both input_ids and inputs_embeds, because they are mutually exclusive ways of specifying the input sequence; supplying both is ambiguous.","triggerScenarios":"encoder(input_ids=ids, inputs_embeds=emb) with both non-None, usually via **kwargs forwarding or incomplete refactors from ID-based to embedding-based inputs.","commonSituations":"Porting NLVR training code between BLIP repo versions; collators that always emit input_ids while the model code adds inputs_embeds.","solutions":["Remove one of the two arguments from the call","Sanitize kwargs in wrappers: kwargs.pop('input_ids', None) before forwarding embeddings","Add a unit test asserting exactly one input source is passed"],"exampleFix":"// before\nloss = model(input_ids=ids, inputs_embeds=emb)\n\n// after\nloss = model(inputs_embeds=emb)","handlingStrategy":"validation","validationCode":"sources = [k for k in ('input_ids', 'inputs_embeds') if locals().get(k) is not None]\nassert len(sources) <= 1, f'conflicting inputs: {sources}'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass inputs explicitly, not via kwargs dictionaries","Pop unused input keys in wrapper layers","Static-search codebases for calls with both arguments"],"tags":["blip","nlvr","input-validation","kwargs"],"backgroundTag":null,"analyzedSha":"ae05379cc97bc4361ec8b4ec90193dab21be763f","analyzedAt":"2026-08-15T04:23:59.533Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}