{"record":{"id":"c9aed2cdd07f994c","repo":"huggingface/transformers","slug":"sequence-bias-has-to-be-a-dict-with-floats-as-va","errorCode":null,"errorMessage":"`sequence_bias` has to be a dict with floats as values, but is {sequence_bias}.","messagePattern":"`sequence_bias` has to be a dict with floats as values, but is (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/transformers/generation/logits_process.py","lineNumber":1386,"sourceCode":"                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            )\n        if isinstance(sequence_bias, dict) and any(not isinstance(bias, float) for bias in sequence_bias.values()):\n            raise ValueError(f\"`sequence_bias` has to be a dict with floats as values, but is {sequence_bias}.\")\n\n    def _convert_list_arguments_into_dict(self):\n        \"\"\"BC: we used to accept `dict{tuple of tokens: float}` directly, now we expect a list\"\"\"\n        if isinstance(self.sequence_bias, list):\n            temp_sequence = self.sequence_bias\n            self.sequence_bias = {tuple(sublist[0]): sublist[1] for sublist in temp_sequence}\n\n\nclass NoBadWordsLogitsProcessor(SequenceBiasLogitsProcessor):\n    \"\"\"\n    [`LogitsProcessor`] that enforces that specified sequences will never be selected.\n\n    <Tip>\n\n    In order to get the token ids of the words that should not appear in the generated text, make sure to set\n    `add_prefix_space=True` when initializing the tokenizer, and use `tokenizer(bad_words,\n    add_special_tokens=False).input_ids`. The `add_prefix_space` argument is only supported for some slow tokenizers,\n    as fast tokenizers' prefixing behaviours come from `pre tokenizers`. Read more","sourceCodeStart":1368,"sourceCodeEnd":1404,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/generation/logits_process.py#L1368-L1404","documentation":"Error \"`sequence_bias` has to be a dict with floats as values, but is {sequence_bias}.\" thrown in huggingface/transformers.","triggerScenarios":"Raised in SequenceBiasLogitsProcessor.__init__ when a sequence_bias dict value is not a float bias.","commonSituations":"Passing ints, strings, or None as bias values in sequence_bias instead of floats.","solutions":["Ensure all values in `sequence_bias` are floats (or ints convertible to float).","Remove non-numeric bias values from the dict."],"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-15T22:17:37.221Z"}