modelscope / AdaSeq

AdaSeq: An All-in-One Library for Developing State-of-the-Art Sequence Understanding Models
Apache License 2.0
418 stars 38 forks source link

[Question] running self trained NER model causes errors #46

Open breadbread1984 opened 3 months ago

breadbread1984 commented 3 months ago

What is your question?

error message:

Traceback (most recent call last):
  File "/root/raid/electrolyte_papers_extraction/NER/ner.py", line 31, in <module>
    ner = NER('ckpt/ner/240731013859.938009/output_best', device = 'gpu')
  File "/root/raid/electrolyte_papers_extraction/NER/ner.py", line 12, in __init__
    self.pipeline = pipeline(Tasks.named_entity_recognition, abspath(ckpt), device = device)
  File "/usr/local/lib/python3.10/dist-packages/modelscope/pipelines/builder.py", line 169, in pipeline
    return build_pipeline(cfg, task_name=task)
  File "/usr/local/lib/python3.10/dist-packages/modelscope/pipelines/builder.py", line 65, in build_pipeline
    return build_from_cfg(
  File "/usr/local/lib/python3.10/dist-packages/modelscope/utils/registry.py", line 215, in build_from_cfg
    raise type(e)(f'{obj_cls.__name__}: {e}')
RuntimeError: SequenceLabelingPipeline: SequenceLabelingModel: TransformerEmbedder: Try loading from huggingface and modelscope failed 

huggingface:
The request model: google-bert/bert-base-cased does not exist!

modelscope:
The request model: google-bert/bert-base-cased does not exist!

self trained NER checkpoint:

https://github.com/breadbread1984/electrolyte_papers_extraction/tree/main/NER/ckpt/ner/240731013859.938009

What have you tried?

under ckpt/ner/. edit <path/to/latest/checkpoint>/output_best/configuration.json to change the following lines

from

    "plugins": [
        "adaseq"
    ]

to

    "plugins": [
        "https://files.pythonhosted.org/packages/49/47/ddf684253dbb4c3e0716fcda67094aa3c407237d5eb8930ede0a91b9feb8/adaseq-0.6.6-py3-none-any.whl"
    ]

Code (if necessary)

source code:

from os.path import abspath
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
pipeline_ = pipeline(Tasks.named_entity_recognition, abspath('ckpt/ner/240731013859.938009/output_best'), device = 'gpu')

What's your environment?

Code of Conduct

1823616178 commented 3 months ago

先把模型下载下来,再把路径添加至配置文件中