hankcs / HanLP

Natural Language Processing for the next decade. Tokenization, Part-of-Speech Tagging, Named Entity Recognition, Syntactic & Semantic Dependency Parsing, Document Classification
https://hanlp.hankcs.com/en/
Apache License 2.0
33.51k stars 9.99k forks source link

" unpack (expected 4, got 3)" from HanLP(['XXXXX']) 运行错误 #1850

Closed 1558359609 closed 11 months ago

1558359609 commented 11 months ago

Describe the bug 在本地运行SDP语义依存分析模型时候出现了bug

Code to reproduce the issue

import hanlp
import torch

xx=hanlp.pretrained.sdp.SEMEVAL15_PSD_BIAFFINE_EN
HanLP = hanlp.load(xx,devices=torch.device('cpu')) 
HanLP(['abc def ghk'])

Describe the current behavior

InvalidArgumentError Traceback (most recent call last) d:\Projects\vscode\oj\oj1.ipynb Cell 3 line 6 4 xx=hanlp.pretrained.sdp.SEMEVAL15_PSD_BIAFFINE_EN 5 HanLP = hanlp.load(xx,devices=torch.device('cpu'))

Expected behavior A clear and concise description of what you expected to happen. ----> 6 HanLP(['abc def ghk'])

File c:\Users\dongyuwu.conda\envs\hanlp\lib\site-packages\hanlp\common\component.py:36, in Component.call(self, *args, kwargs) 25 def call(self, *args, *kwargs): 26 """ 27 A shortcut for :func:~hanlp.common.component.predict. 28 (...) 34 35 """ ---> 36 return self.predict(args, kwargs)

File c:\Users\dongyuwu.conda\envs\hanlp\lib\site-packages\hanlp\common\keras_component.py:479, in KerasComponent.predict(self, data, batch_size, **kwargs) 477 data_is_list = isinstance(data, list) 478 print(dataset) --> 479 for idx, batch in enumerate(dataset): 480 samples_in_batch = tf.shape( 481 batch[-1] if isinstance(batch[-1], tf.Tensor) else batch[-1][0])[0] 482 if data_is_list: ...

ValueError: not enough values to unpack (expected 4, got 3)

 [[{{node PyFunc}}]] [Op:IteratorGetNext] name:

System information

Other info / logs Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.

hankcs commented 11 months ago

https://github.com/hankcs/HanLP/blob/doc-zh/plugins/hanlp_demo/hanlp_demo/en/demo_sdp.py#L11