啊,被hanlp整烦了。
我从github上把hanlp克隆下来,然后运行两行代码,就报错了。以下是代码:
import hanlp
HanLP = hanlp.load(hanlp.pretrained.mtl.UD_ONTONOTES_TOK_POS_LEM_FEA_NER_SRL_DEP_SDP_CON_XLMR_BASE)
看错误提示是会下载一个包,可是不管是我手动下载,还是程序自动下载,都会报错。
后来load函数的参数我换了别的,还是这样。
HanLP = hanlp.load(hanlp.pretrained.mtl.CLOSE_TOK_POS_NER_SRL_DEP_SDP_CON_ELECTRA_SMALL_ZH)
后来我去查issue,看到2月份有个哥们碰到类似的。https://github.com/hankcs/HanLP/issues/1618
issue里作者说要用最新版本的master。我试过了依然没用。后来看到下面作者提到的 171bd2d 版本,我切换过去了,能跑CLOSE_TOK_POS_NER_SRL_DEP_SDP_CON_ELECTRA_SMALL_ZH,但是UD_ONTONOTES_TOK_POS_LEM_FEA_NER_SRL_DEP_SDP_CON_XLMR_BASE由于url过期了,还是跑不了。
我到底怎么办啊?都磨了一天一夜了。
Failed to load https://file.hankcs.com/hanlp/mtl/ud_ontonotes_tok_pos_lem_fea_ner_srl_dep_sdp_con_xlm_base_20210602_211620.zip. See traceback below:
================================ERROR LOG BEGINS================================
Traceback (most recent call last):
File “D:\Python\Python39\lib\site-packages\hanlp-2.1.0a51-py3.9.egg\hanlp\utils\component_util.py”, line 81, in load_from_meta_file
obj.load(save_dir, verbose=verbose, **kwargs)
File “D:\Python\Python39\lib\site-packages\hanlp-2.1.0a51-py3.9.egg\hanlp\common\torch_component.py”, line 173, in load
self.load_config(save_dir, **kwargs)
m_config
return cls(**deserialized_config)
File “D:\Python\Python39\lib\site-packages\hanlp-2.1.0a51-py3.9.egg\hanlp\layers\embeddings\contextual_word_embedding.py”, line 141, in init
self.transformer_tokenizer = AutoTokenizer.from_pretrained(self.transformer,
File “D:\Python\Python39\lib\site-packages\hanlp-2.1.0a51-py3.9.egg\hanlp\layers\transformers\pt_imports.py”, line 65, in from_pretrained
tokenizer = cls.from_pretrained(get_mirror(transformer), use_fast=use_fast, do_basic_tokenize=do_basic_tokenize,
File “D:\Python\Python39\lib\site-packages\transformers\models\auto\tokenization_auto.py”, line 523, in from_pretrained
tokenizer_config = get_tokenizer_config(pretrained_model_name_or_path, **kwargs)
File “D:\Python\Python39\lib\site-packages\transformers\models\auto\tokenization_auto.py”, line 416, in get_tokenizer_config
resolved_config_file = cached_path(
File “D:\Python\Python39\lib\site-packages\transformers\file_utils.py”, line 1347, in cached_path
raise ValueError(f"unable to parse {url_or_filename} as a URL or as a local path")
ValueError: unable to parse C:\Users\dashe\AppData\Roaming\hanlp\hanlp\transformers\xlm-roberta-base_20210526_112208\tokenizer_config.json as a URL or as a local path
=================================ERROR LOG ENDS=================================
If the problem still persists, please submit an issue to https://github.com/hankcs/HanLP/issues
When reporting an issue, make sure to paste the FULL ERROR LOG above and the system info below.
OS: Windows-10-10.0.19041-SP0
Python: 3.9.2
PyTorch: 1.9.0+cpu
HanLP: 2.1.0-alpha.51
PS E:\project\sicp\py>
PS E:\project\sicp\py>
PS E:\project\sicp\py>
PS E:\project\sicp\py> python server.py
Decompressing C:\Users\dashe\AppData\Roaming\hanlp\hanlp\mtl\ud_ontonotes_tok_pos_lem_fea_ner_srl_dep_sdp_con_xlm_base_20210602_211620.zip to C:\Users\dashe\AppData\Roaming\hanlp\hanlp\mtl
Failed to load https://file.hankcs.com/hanlp/mtl/ud_ontonotes_tok_pos_lem_fea_ner_srl_dep_sdp_con_xlm_base_20210602_211620.zip. See traceback below:
================================ERROR LOG BEGINS================================
Traceback (most recent call last):
File “D:\Python\Python39\lib\site-packages\hanlp-2.1.0a51-py3.9.egg\hanlp\utils\component_util.py”, line 81, in load_from_meta_file
obj.load(save_dir, verbose=verbose, **kwargs)
File “D:\Python\Python39\lib\site-packages\hanlp-2.1.0a51-py3.9.egg\hanlp\common\torch_component.py”, line 173, in load
self.load_config(save_dir, **kwargs)
d_config
self.config[k] = Configurable.from_config(v)
File “D:\Python\Python39\lib\site-packages\hanlp_common-0.0.9-py3.9.egg\hanlp_common\configurable.py”, line 30, in from_config
return cls(**deserialized_config)
File “D:\Python\Python39\lib\site-packages\hanlp-2.1.0a51-py3.9.egg\hanlp\layers\embeddings\contextual_word_embedding.py”, line 141, in init
self.transformer_tokenizer = AutoTokenizer.from_pretrained(self.transformer,
File “D:\Python\Python39\lib\site-packages\hanlp-2.1.0a51-py3.9.egg\hanlp\layers\transformers\pt_imports.py”, line 65, in from_pretrained
tokenizer = cls.from_pretrained(get_mirror(transformer), use_fast=use_fast, do_basic_tokenize=do_basic_tokenize,
File “D:\Python\Python39\lib\site-packages\transformers\models\auto\tokenization_auto.py”, line 523, in from_pretrained
tokenizer_config = get_tokenizer_config(pretrained_model_name_or_path, **kwargs)
File “D:\Python\Python39\lib\site-packages\transformers\models\auto\tokenization_auto.py”, line 416, in get_tokenizer_config
resolved_config_file = cached_path(
File “D:\Python\Python39\lib\site-packages\transformers\file_utils.py”, line 1347, in cached_path
raise ValueError(f"unable to parse {url_or_filename} as a URL or as a local path")
ValueError: unable to parse C:\Users\dashe\AppData\Roaming\hanlp\hanlp\transformers\xlm-roberta-base_20210526_112208\tokenizer_config.json as a URL or as a local path
=================================ERROR LOG ENDS=================================
If the problem still persists, please submit an issue to https://github.com/hankcs/HanLP/issues
When reporting an issue, make sure to paste the FULL ERROR LOG above and the system info below.
OS: Windows-10-10.0.19041-SP0
Python: 3.9.2
PyTorch: 1.9.0+cpu
HanLP: 2.1.0-alpha.51
PS E:\project\sicp\py> python server.py
Failed to load https://file.hankcs.com/hanlp/mtl/ud_ontonotes_tok_pos_lem_fea_ner_srl_dep_sdp_con_xlm_base_20210602_211620.zip. See traceback below:
================================ERROR LOG BEGINS================================
Traceback (most recent call last):
File “D:\Python\Python39\lib\site-packages\hanlp-2.1.0a51-py3.9.egg\hanlp\utils\component_util.py”, line 81, in load_from_meta_file
obj.load(save_dir, verbose=verbose, **kwargs)
File “D:\Python\Python39\lib\site-packages\hanlp-2.1.0a51-py3.9.egg\hanlp\common\torch_component.py”, line 173, in load
self.load_config(save_dir, **kwargs)
File “D:\Python\Python39\lib\site-packages\hanlp-2.1.0a51-py3.9.egg\hanlp\common\torch_component.py”, line 125, in load_config
self.config[k] = Configurable.from_config(v)
File “D:\Python\Python39\lib\site-packages\hanlp_common-0.0.9-py3.9.egg\hanlp_common\configurable.py”, line 30, in from_config
return cls(**deserialized_config)
File “D:\Python\Python39\lib\site-packages\hanlp-2.1.0a51-py3.9.egg\hanlp\layers\embeddings\contextual_word_embedding.py”, line 141, in init
self.transformer_tokenizer = AutoTokenizer.from_pretrained(self.transformer,
File “D:\Python\Python39\lib\site-packages\hanlp-2.1.0a51-py3.9.egg\hanlp\layers\transformers\pt_imports.py”, line 65, in from_pretrained
tokenizer = cls.from_pretrained(get_mirror(transformer), use_fast=use_fast, do_basic_tokenize=do_basic_tokenize,
File “D:\Python\Python39\lib\site-packages\transformers\models\auto\tokenization_auto.py”, line 523, in from_pretrained
tokenizer_config = get_tokenizer_config(pretrained_model_name_or_path, **kwargs)
File “D:\Python\Python39\lib\site-packages\transformers\models\auto\tokenization_auto.py”, line 416, in get_tokenizer_config
resolved_config_file = cached_path(
File “D:\Python\Python39\lib\site-packages\transformers\file_utils.py”, line 1347, in cached_path
raise ValueError(f"unable to parse {url_or_filename} as a URL or as a local path")
ValueError: unable to parse C:\Users\dashe\AppData\Roaming\hanlp\hanlp\transformers\xlm-roberta-base_20210526_112208\tokenizer_config.json as a URL or as a local path
=================================ERROR LOG ENDS=================================
If the problem still persists, please submit an issue to https://github.com/hankcs/HanLP/issues
When reporting an issue, make sure to paste the FULL ERROR LOG above and the system info below.
OS: Windows-10-10.0.19041-SP0
Python: 3.9.2
PyTorch: 1.9.0+cpu
HanLP: 2.1.0-alpha.51