{"record":{"id":"a807240c600a8089","repo":"huggingface/transformers","slug":"require-guidance-scale-1-to-use-the-classifier-fr","errorCode":null,"errorMessage":"Require guidance scale >1 to use the classifier free guidance processor, got guidance scale {guidance_scale}.","messagePattern":"Require guidance scale >1 to use the classifier free guidance processor, got guidance scale (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/transformers/generation/logits_process.py","lineNumber":2158,"sourceCode":"    >>> from transformers import AutoProcessor, MusicgenForConditionalGeneration\n\n    >>> processor = AutoProcessor.from_pretrained(\"facebook/musicgen-small\")\n    >>> model = MusicgenForConditionalGeneration.from_pretrained(\"facebook/musicgen-small\")\n\n    >>> inputs = processor(\n    ...     text=[\"80s pop track with bassy drums and synth\", \"90s rock song with loud guitars and heavy drums\"],\n    ...     padding=True,\n    ...     return_tensors=\"pt\",\n    ... )\n    >>> audio_values = model.generate(**inputs, do_sample=True, guidance_scale=3, max_new_tokens=256)\n    ```\n    \"\"\"\n\n    def __init__(self, guidance_scale):\n        if guidance_scale > 1:\n            self.guidance_scale = guidance_scale\n        else:\n            raise ValueError(\n                \"Require guidance scale >1 to use the classifier free guidance processor, got guidance scale \"\n                f\"{guidance_scale}.\"\n            )\n\n    @add_start_docstrings(LOGITS_PROCESSOR_INPUTS_DOCSTRING)\n    def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor) -> torch.FloatTensor:\n        # simple check to make sure we have compatible batch sizes between our\n        # logits scores (cond + uncond) and input ids (cond only)\n        if scores.shape[0] != 2 * input_ids.shape[0]:\n            raise ValueError(\n                f\"Logits should have twice the batch size of the input ids, the first half of batches corresponding to \"\n                f\"the conditional inputs, and the second half of batches corresponding to the unconditional inputs. Got \"\n                f\"batch size {scores.shape[0]} for the logits and {input_ids.shape[0]} for the input ids.\"\n            )\n        unguided_bsz = scores.shape[0] // 2\n        cond_logits, uncond_logits = scores.split(unguided_bsz, dim=0)\n        scores_processed = uncond_logits + (cond_logits - uncond_logits) * self.guidance_scale\n        return scores_processed","sourceCodeStart":2140,"sourceCodeEnd":2176,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/generation/logits_process.py#L2140-L2176","documentation":"Error \"Require guidance scale >1 to use the classifier free guidance processor, got guidance scale {guidance_scale}.\" thrown in huggingface/transformers.","triggerScenarios":"Raised in ClassifierFreeGuidanceLogitsProcessor.__init__ when guidance_scale <= 1.","commonSituations":"Classifier-free guidance decoding with guidance_scale set to 1.0 or lower, where CFG has no effect and the processor rejects it.","solutions":["Set `guidance_scale` to a value greater than 1 (e.g. 7.5) when using classifier-free guidance.","Remove the classifier-free guidance processor if guidance is not needed."],"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"}