{"record":{"id":"23857a3db17eb382","repo":"hankcs/HanLP","slug":"unsupported-argument-length-item","errorCode":null,"errorMessage":"Unsupported argument length: {item}","messagePattern":"Unsupported argument length: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"hanlp/common/transform.py","lineNumber":83,"sourceCode":"\n\nclass VocabList(list):\n\n    def __init__(self, *fields) -> None:\n        super().__init__()\n        for each in fields:\n            self.append(FieldToIndex(each))\n\n    def append(self, item: Union[str, Tuple[str, Vocab], Tuple[str, str, Vocab], FieldToIndex]) -> None:\n        if isinstance(item, str):\n            item = FieldToIndex(item)\n        elif isinstance(item, (list, tuple)):\n            if len(item) == 2:\n                item = FieldToIndex(src=item[0], vocab=item[1])\n            elif len(item) == 3:\n                item = FieldToIndex(src=item[0], dst=item[1], vocab=item[2])\n            else:\n                raise ValueError(f'Unsupported argument length: {item}')\n        elif isinstance(item, FieldToIndex):\n            pass\n        else:\n            raise ValueError(f'Unsupported argument type: {item}')\n        super(self).append(item)\n\n    def save_vocab(self, save_dir):\n        for each in self:\n            each.save_vocab(save_dir, None)\n\n    def load_vocab(self, save_dir):\n        for each in self:\n            each.load_vocab(save_dir, None)\n\n\nclass VocabDict(SerializableDict):\n\n    def __init__(self, *args, **kwargs) -> None:","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/common/transform.py#L65-L101","documentation":"evaluate_dataloader on Word2VecEmbedding always raises NotImplementedError because evaluation with a loss/metric requires a trainable prediction model, which a static embedding is not. The method exists only to satisfy the Component interface.","triggerScenarios":"Calling evaluate_dataloader (or .evaluate()) on a Word2VecEmbedding, e.g. from a generic evaluation harness.","commonSituations":"Running a benchmark script over a list of models that includes pure embeddings; validating a pipeline whose head was accidentally replaced by an embedding module.","solutions":["Evaluate the task component that consumes the embedding, not the embedding itself","Guard calls with isinstance checks in generic eval loops","Subclass to provide a custom evaluation if needed"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"if isinstance(model, Word2VecEmbedding):\n    raise TypeError('evaluate a task component, not an embedding')","typeGuard":"def evaluatable(m) -> bool: return not isinstance(m, Word2VecEmbedding)","tryCatchPattern":"try:\n    model.evaluate_dataloader(data, criterion, metric)\nexcept NotImplementedError as e:\n    raise RuntimeError('inference-only component') from e","preventionTips":["Exclude embedding modules from benchmark suites","Assert the model has a prediction head before evaluating"],"tags":["hanlp","evaluation","embedding","not-implemented"],"backgroundTag":"not-implemented-error","analyzedSha":"ddb1299bddff079e447af52ec12549c50636bfa8","analyzedAt":"2026-08-27T03:36:54.287Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}