Skip to content

[Bug]: ner = Taskflow("ner")初始化失败 #11004

@nationdef

Description

@nationdef

软件环境

paddle2onnx               2.0.2rc3
paddlefsl                 1.1.0
paddlenlp                 3.0.0b4
paddlepaddle-gpu          3.1.1

重复问题

  • I have searched the existing issues

错误描述

[2025-08-26 07:11:06,113] [    INFO] - Downloading model_state.pdparams from https://bj.bcebos.com/paddlenlp/taskflow/knowledge_mining/wordtag_v1.5/model_state.pdparams
100%|██████████| 367M/367M [00:34<00:00, 11.1MB/s]
[2025-08-26 07:11:41,788] [    INFO] - Downloading config.json from https://bj.bcebos.com/paddlenlp/taskflow/knowledge_mining/wordtag_v1.1/config.json
100%|██████████| 16.8k/16.8k [00:00<00:00, 907kB/s]
[2025-08-26 07:11:41,962] [    INFO] - Downloading tags.txt from https://bj.bcebos.com/paddlenlp/taskflow/knowledge_mining/wordtag_v1.1/tags.txt
100%|██████████| 7.58k/7.58k [00:00<00:00, 22.8MB/s]
[2025-08-26 07:11:42,088] [    INFO] - Downloading vocab.txt from https://bj.bcebos.com/paddlenlp/taskflow/knowledge_mining/wordtag/vocab.txt
100%|██████████| 89.6k/89.6k [00:00<00:00, 533kB/s]
[2025-08-26 07:11:42,393] [    INFO] - Downloading special_tokens_map.json from https://bj.bcebos.com/paddlenlp/taskflow/knowledge_mining/wordtag/special_tokens_map.json
100%|██████████| 90.0/90.0 [00:00<00:00, 532kB/s]
[2025-08-26 07:11:42,579] [    INFO] - Downloading tokenizer_config.json from https://bj.bcebos.com/paddlenlp/taskflow/knowledge_mining/wordtag/tokenizer_config.json
100%|██████████| 252/252 [00:00<00:00, 1.58MB/s]
[2025-08-26 07:11:42,730] [    INFO] - Loading configuration file /home/pyUser/.paddlenlp/taskflow/wordtag/config.json
[2025-08-26 07:11:42,730] [    INFO] - Loading weights file /home/pyUser/.paddlenlp/taskflow/wordtag/model_state.pdparams
[2025-08-26 07:11:43,035] [    INFO] - Loaded weights file from disk, setting weights to model.
W0826 07:11:43.143414 30158 gpu_resources.cc:114] Please NOTE: device: 0, GPU Compute Capability: 8.9, Driver API Version: 12.9, Runtime API Version: 12.9
[2025-08-26 07:11:43,266] [ WARNING] - Some weights of the model checkpoint at /home/pyUser/.paddlenlp/taskflow/wordtag were not used when initializing ErnieCtmWordtagModel: ['sent_classifier.bias', 'sent_classifier.weight']
- This IS expected if you are initializing ErnieCtmWordtagModel from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).
- This IS NOT expected if you are initializing ErnieCtmWordtagModel from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).
[2025-08-26 07:11:43,266] [ WARNING] - Some weights of ErnieCtmWordtagModel were not initialized from the model checkpoint at /home/pyUser/.paddlenlp/taskflow/wordtag and are newly initialized: ['viterbi_decoder.transitions', 'crf_loss.crf.transitions']
You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.
[2025-08-26 07:11:43,269] [    INFO] - Converting to the inference model cost a little time.
[2025-08-26 07:11:44,074] [    INFO] - The inference model save in the path:/home/pyUser/.paddlenlp/taskflow/wordtag/static/inference
Traceback (most recent call last):
  File "/home/pyUser/proDB/project-ml/deeplearn-case/data_processing/paddlenlp_demo.py", line 16, in <module>
    ner = Taskflow("ner")
          ^^^^^^^^^^^^^^^
  File "/home/pyUser/miniconda3/lib/python3.12/site-packages/paddlenlp/taskflow/taskflow.py", line 869, in __init__
    self.task_instance = task_class(
                         ^^^^^^^^^^^
  File "/home/pyUser/miniconda3/lib/python3.12/site-packages/paddlenlp/taskflow/named_entity_recognition.py", line 123, in __init__
    super().__init__(model="wordtag", task=task, **kwargs)
  File "/home/pyUser/miniconda3/lib/python3.12/site-packages/paddlenlp/taskflow/knowledge_mining.py", line 235, in __init__
    self._get_inference_model()
  File "/home/pyUser/miniconda3/lib/python3.12/site-packages/paddlenlp/taskflow/task.py", line 401, in _get_inference_model
    self._prepare_static_mode()
  File "/home/pyUser/miniconda3/lib/python3.12/site-packages/paddlenlp/taskflow/task.py", line 247, in _prepare_static_mode
    self.predictor = paddle.inference.create_predictor(self._config)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: (InvalidArgument) The shape of Input(x) and input(residual) do not match: 128 vs 0.
  [Hint: Expected x_dims_vec[i] == residual_dims_vec[i], but received x_dims_vec[i]:128 != residual_dims_vec[i]:0.] (at /paddle/paddle/phi/infermeta/multiary.cc:2639)

稳定复现步骤 & 代码

初始化“ner”时报错,但“word_segmentation”, “information_extraction”都正常

from paddlenlp import Taskflow
ner = Taskflow("ner")

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions