{"record":{"id":"9410a28c75895dc2","repo":"PaddlePaddle/PaddleOCR","slug":"make-sure-that-all-the-required-parameters-list","errorCode":null,"errorMessage":"Make sure that all the required parameters: {list(function_args.keys())} for {processor.__class__} are passed to the logits processor.","messagePattern":"Make sure that all the required parameters: (.+?) for (.+?) are passed to the logits processor\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"ppocr/modeling/heads/rec_unimernet_head.py","lineNumber":1569,"sourceCode":"        )\n\n        return attn_output, attn_output_weights\n\n\nclass LogitsProcessorList(list):\n    \"\"\"\n    A list of logits processors that can be applied sequentially.\n\n    Methods:\n        __call__(input_ids, scores, **kwargs): Apply all processors to the given inputs.\n    \"\"\"\n\n    def __call__(self, input_ids, scores, **kwargs):\n        for processor in self:\n            function_args = inspect.signature(processor.__call__).parameters\n            if len(function_args) > 2:\n                if not all(arg in kwargs for arg in list(function_args.keys())[2:]):\n                    raise ValueError(\n                        f\"Make sure that all the required parameters: {list(function_args.keys())} for \"\n                        f\"{processor.__class__} are passed to the logits processor.\"\n                    )\n                scores = processor(input_ids, scores, **kwargs)\n            else:\n                scores = processor(input_ids, scores)\n        return scores\n\n\nclass ForcedEOSTokenLogitsProcessor(object):\n    \"\"\"\n    A processor that forces the generation of an end-of-sequence (EOS) token\n    at a specified position in the sequence.\n\n    This is typically used in language generation tasks to ensure that the\n    generated sequence ends properly when it reaches a certain length.\n\n    Args:","sourceCodeStart":1551,"sourceCodeEnd":1587,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/ppocr/modeling/heads/rec_unimernet_head.py#L1551-L1587","documentation":"LogitsProcessorList.__call__ inspects each processor's __call__ signature; any parameter beyond (input_ids, scores) must be supplied via kwargs. If one is missing, it raises this ValueError because calling the processor would itself raise a TypeError, and the explicit message names the expected parameters.","triggerScenarios":"Running generation with processors such as MinLengthLogitsProcessor (needs min_length) or ForcedEOSTokenLogitsProcessor (needs forced eos id) while the generate loop / custom loop does not pass those kwargs to logits_processor(input_ids, scores, **kwargs).","commonSituations":"Custom generate implementations (like the one in this head) that forward a fixed set of kwargs; adding a new processor to logits_processor list without updating the generation loop to supply its arguments.","solutions":["Pass the missing kwarg(s) into the logits_processor call, e.g. logits_processor(input_ids, scores, min_length=cfg.min_length, eos_token_id=cfg.eos_token_id)","Or remove the processor that requires unavailable arguments","Wrap processor construction so required args are bound via functools.partial, reducing the signature to (input_ids, scores)"],"exampleFix":"# before\nnext_tokens_scores = self.logits_processor(input_ids, next_token_logits)\n# after\nnext_tokens_scores = self.logits_processor(\n    input_ids, next_token_logits,\n    min_length=self.config.min_length,\n    eos_token_id=eos_token_id,\n)","handlingStrategy":"validation","validationCode":"import inspect\nrequired = [p for p in inspect.signature(processor.__call__).parameters][2:]\nmissing = [a for a in required if a not in generation_kwargs]\nassert not missing, f'logits processor missing kwargs: {missing}'","typeGuard":null,"tryCatchPattern":"try:\n    scores = logits_processor(input_ids, scores, **gen_kwargs)\nexcept ValueError as e:\n    if 'passed to the logits processor' in str(e):\n        gen_kwargs.update(min_length=cfg.min_length, eos_token_id=eos_id)\n        scores = logits_processor(input_ids, scores, **gen_kwargs)\n    else:\n        raise","preventionTips":["Bind processor-specific args with functools.partial at construction","Keep a single gen_kwargs dict passed to every logits_processor call"],"tags":["paddle","generation","logits-processor","missing-argument"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}