{"record":{"id":"524e886bb2af38ce","repo":"huggingface/transformers","slug":"each-key-in-sequence-bias-has-to-be-a-non-empty","errorCode":null,"errorMessage":"Each key in `sequence_bias` has to be a non-empty tuple of positive integers, but is {sequence_bias}.","messagePattern":"Each key in `sequence_bias` has to be a non-empty tuple of positive integers, but is (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/transformers/generation/logits_process.py","lineNumber":1366,"sourceCode":"            self.length_1_bias[single_token_ids] = torch.tensor(single_token_biases, device=scores.device)\n        self.prepared_bias_variables = True\n\n    def _validate_arguments(self):\n        sequence_bias = self.sequence_bias\n        if not isinstance(sequence_bias, dict) and not isinstance(sequence_bias, list) or len(sequence_bias) == 0:\n            raise ValueError(\n                f\"`sequence_bias` has to be a non-empty dictionary, or non-empty list of lists but is {sequence_bias}.\"\n            )\n        if isinstance(sequence_bias, dict) and any(\n            not isinstance(sequence_ids, tuple) for sequence_ids in sequence_bias\n        ):\n            raise ValueError(f\"`sequence_bias` has to be a dict with tuples as keys, but is {sequence_bias}.\")\n        if isinstance(sequence_bias, dict) and any(\n            any((not isinstance(token_id, (int, np.integer)) or token_id < 0) for token_id in sequence_ids)\n            or len(sequence_ids) == 0\n            for sequence_ids in sequence_bias\n        ):\n            raise ValueError(\n                f\"Each key in `sequence_bias` has to be a non-empty tuple of positive integers, but is \"\n                f\"{sequence_bias}.\"\n            )\n\n        def all_token_bias_pairs_are_valid(sequence):\n            return (\n                isinstance(sequence[0], list)\n                and all(isinstance(token_id, (int, np.integer)) and token_id > 0 for token_id in sequence[0])\n                and isinstance(sequence[1], float)\n            )\n\n        if isinstance(sequence_bias, list) and any(\n            (not all_token_bias_pairs_are_valid(sequence)) or len(sequence) == 0 for sequence in sequence_bias\n        ):\n            raise ValueError(\n                f\"Each element in `sequence_bias` has to be a non-empty list of lists of positive integers and float, but is \"\n                f\"{sequence_bias}.\"\n            )","sourceCodeStart":1348,"sourceCodeEnd":1384,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/generation/logits_process.py#L1348-L1384","documentation":"Error \"Each key in `sequence_bias` has to be a non-empty tuple of positive integers, but is {sequence_bias}.\" thrown in huggingface/transformers.","triggerScenarios":"Raised in SequenceBiasLogitsProcessor.__init__ when a sequence_bias dict key is an empty tuple, a non-tuple, or contains token ids that are not positive integers.","commonSituations":"Supplying sequence_bias keys with zero/negative token ids or empty tuples, typically from programmatic construction of the bias mapping.","solutions":["Ensure every key in `sequence_bias` is a non-empty tuple of positive integer token ids.","Remove empty tuples or non-positive token ids from the keys."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}