PaddlePaddle / PaddleHub

Awesome pre-trained models toolkit based on PaddlePaddle. (400+ models including Image, Text, Audio, Video and Cross-Modal with Easy Inference & Serving)
https://www.paddlepaddle.org.cn/hub
Apache License 2.0
12.67k stars 2.07k forks source link

sequence_labeling示例代码报错 #1923

Open maidangdang1 opened 2 years ago

maidangdang1 commented 2 years ago

欢迎您反馈PaddleHub使用问题,非常感谢您对PaddleHub的贡献! 在留下您的问题时,辛苦您同步提供如下信息:

paddlepaddle 2.3.1,paddlehub 2.2.0

2)系统环境:请您描述系统类型,例如Linux/Windows/MacOS/,python版本

Linux,python3.9.12

直接copy运行PaddleHub/demo/sequence_labeling/train.py里面的代码,报keyerror

[2022-08-04 04:12:23,852] [ WARNING] - PaddleHub model checkpoint not found, start from scratch...
[2022-08-04 04:12:29,136] [ WARNING] - Compatibility Warning: The params of ChunkEvaluator.compute has been modified. The old version is `inputs`, `lengths`, `predictions`, `labels` while the current version is `lengths`, `predictions`, `labels`.  Please update the usage.
Traceback (most recent call last):
  File "/home/team_W/mmt/paddleNERtest.py", line 55, in <module>
    trainer.train(
  File "/home/team_W/anaconda3/envs/mmt_test/lib/python3.9/site-packages/paddlehub/finetune/trainer.py", line 212, in train
    loss, metrics = self.training_step(batch, batch_idx)
  File "/home/team_W/anaconda3/envs/mmt_test/lib/python3.9/site-packages/paddlehub/finetune/trainer.py", line 352, in training_step
    result = self.model.training_step(batch, batch_idx)
  File "/home/team_W/anaconda3/envs/mmt_test/lib/python3.9/site-packages/paddlehub/module/nlp_module.py", line 504, in training_step
    predictions, avg_loss, metric = self(
  File "/home/team_W/anaconda3/envs/mmt_test/lib/python3.9/site-packages/paddle/fluid/dygraph/layers.py", line 930, in __call__
    return self._dygraph_call_func(*inputs, **kwargs)
  File "/home/team_W/anaconda3/envs/mmt_test/lib/python3.9/site-packages/paddle/fluid/dygraph/layers.py", line 915, in _dygraph_call_func
    outputs = self.forward(*inputs, **kwargs)
  File "/home/team_W/.paddlehub/modules/ernie_tiny/module.py", line 105, in forward
    self.metric.compute(None, seq_lengths, preds, labels)
  File "/home/team_W/anaconda3/envs/mmt_test/lib/python3.9/site-packages/paddlenlp/metrics/chunk.py", line 104, in compute
    unpad_labels = [[
  File "/home/team_W/anaconda3/envs/mmt_test/lib/python3.9/site-packages/paddlenlp/metrics/chunk.py", line 104, in <listcomp>
    unpad_labels = [[
  File "/home/team_W/anaconda3/envs/mmt_test/lib/python3.9/site-packages/paddlenlp/metrics/chunk.py", line 105, in <listcomp>
    self.id2label_dict[index]
KeyError: -100

麻烦看看是什么问题😭

rainyfly commented 2 years ago

看起来这个报错是paddlenlp中出来的,请问paddlenlp的版本号是?

maidangdang1 commented 2 years ago

在paddlenlp 2.3.3和2.3.4都会报错,我回退到paddlenlp 2.1.1就正常了