{"record":{"id":"1cf963bb82a0cd16","repo":"PaddlePaddle/PaddleOCR","slug":"error","errorCode":null,"errorMessage":"error!!!!!!","messagePattern":"error!!!!!!","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"ppocr/losses/distillation_loss.py","lineNumber":1139,"sourceCode":"        elif self.mode == \"sum\":\n            return self.forward_sum(stu_out, tea_out)\n        elif self.mode == \"meanlog\":\n            blank_mask = paddle.ones_like(stu_out)\n            blank_mask.stop_gradient = True\n            blank_mask[:, :, 0] = -1\n            stu_out *= blank_mask\n            tea_out *= blank_mask\n            return self.forward_meanlog(stu_out, tea_out)\n        elif self.mode == \"ctcdkd\":\n            # ignore ctc blank logits\n            blank_mask = paddle.ones_like(stu_out)\n            blank_mask.stop_gradient = True\n            blank_mask[:, :, 0] = -1\n            stu_out *= blank_mask\n            tea_out *= blank_mask\n            return self.ctc_dkd_loss(stu_out, tea_out, targets)\n        else:\n            raise ValueError(\"error!!!!!!\")\n\n    def forward_log(self, out1, out2):\n        if self.act is not None:\n            out1 = self.act(out1) + 1e-10\n            out2 = self.act(out2) + 1e-10\n        if self.use_log is True:\n            # for recognition distillation, log is needed for feature map\n            log_out1 = paddle.log(out1)\n            log_out2 = paddle.log(out2)\n            loss = (self._kldiv(log_out1, out2) + self._kldiv(log_out2, out1)) / 2.0\n\n        return loss\n\n\nclass DistillCTCLogits(KLCTCLogits):\n    def __init__(\n        self, model_name_pairs=[], key=None, name=\"ctc_logits\", reduction=\"mean\"\n    ):","sourceCodeStart":1121,"sourceCodeEnd":1157,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/ppocr/losses/distillation_loss.py#L1121-L1157","documentation":"This is the fallback branch of a distillation loss's forward: it dispatches on self.mode, which must be one of 'log', 'mean', 'sum', 'meanlog' or 'ctcdkd'. An unrecognized mode reaches the else and raises the unhelpful ValueError('error!!!!!!') — the message gives no clue, but the cause is always an invalid mode string on this specific loss class (the mode selection in the distillation YAML, e.g. for the ctc/attention distill loss).","triggerScenarios":"Building a DistillationModel loss item whose mode is misspelled or from a different loss class (e.g. mode: ' CEL ' with spaces, or a mode valid for KLJSLoss like 'kl' but not for this loss), then running forward during training.","commonSituations":"Hand-editing a distillation config and reusing a mode from another distill loss; mode/config mismatch after upgrading PaddleOCR where supported mode names changed; the error surfaces only at the first training step, not at config parse time.","solutions":["Find the distillation loss config whose forward hits this line and set mode to one of: 'log', 'mean', 'sum', 'meanlog', 'ctcdkd'","Match the mode to the loss class: 'ctcdkd' belongs to the CTC distill loss; check the loss's own mode branches before choosing","Add a quick assert at startup: assert loss.mode in {'log','mean','sum','meanlog','ctcdkd'} to fail at config time instead of mid-training"],"exampleFix":"# before (distillation config yaml)\nmode: kl        # ValueError: 'error!!!!!!' at first step\n\n# after\nmode: meanlog","handlingStrategy":"validation","validationCode":"DISTILL_MODES = {'log', 'mean', 'sum', 'meanlog', 'ctcdkd'}\nassert cfg['mode'] in DISTILL_MODES, f\"distill loss mode must be one of {sorted(DISTILL_MODES)}, got {cfg['mode']!r}\"","typeGuard":"def is_distill_mode(m: str) -> bool:\n    return isinstance(m, str) and m in {'log', 'mean', 'sum', 'meanlog', 'ctcdkd'}","tryCatchPattern":"try:\n    loss = distill_loss(student_out, teacher_out, targets)\nexcept ValueError as e:\n    if 'error' in str(e):\n        raise ValueError(f'Invalid distillation mode {distill_loss.mode!r}; expected one of log/mean/sum/meanlog/ctcdkd') from e\n    raise","preventionTips":["The message 'error!!!!!!' carries no info — always validate the mode string yourself at config-load time","Modes differ per distillation loss class; whitelist per class, not globally","Fail at startup (construct + assert mode) rather than at the first training step"],"tags":["config","distillation","loss","poor-error-message"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}