OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows-10-10.0.22631-SP0
Python: 3.11.7
PyTorch: 2.3.1+cu121
TensorFlow: 2.17.0
HanLP: 2.1.0-beta.58
Other info / logs
Failed to load https://file.hankcs.com/hanlp/sdp/semeval15_biaffine_pas_20200103_152405.zip
================================ERROR LOG BEGINS================================
Traceback (most recent call last):
File "c:\Users\win11\Desktop\thesis\study\SDP.py", line 3, in <module>
hanlp.load('SEMEVAL15_PAS_BIAFFINE_EN')
File "C:\Users\win11\AppData\Local\Programs\Python\Python311\Lib\site-packages\hanlp\__init__.py", line 43, in load
return load_from_meta_file(save_dir, 'meta.json', verbose=verbose, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\win11\AppData\Local\Programs\Python\Python311\Lib\site-packages\hanlp\utils\component_util.py", line 186, in load_from_meta_file
raise e from None
File "C:\Users\win11\AppData\Local\Programs\Python\Python311\Lib\site-packages\hanlp\utils\component_util.py", line 106, in load_from_meta_file
obj.load(save_dir, verbose=verbose, **kwargs)
File "C:\Users\win11\AppData\Local\Programs\Python\Python311\Lib\site-packages\hanlp\common\keras_component.py", line 215, in load
self.build(**merge_dict(self.config, training=False, logger=logger, **kwargs, overwrite=True, inplace=True))
File "C:\Users\win11\AppData\Local\Programs\Python\Python311\Lib\site-packages\hanlp\common\keras_component.py", line 225, in build
self.model = self.build_model(**merge_dict(self.config, training=kwargs.get('training', None),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\win11\AppData\Local\Programs\Python\Python311\Lib\site-packages\hanlp\components\parsers\biaffine_parser_tf.py", line 42, in build_model
pretrained: tf.keras.layers.Embedding = build_embedding(pretrained_embed, self.transform.form_vocab,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\win11\AppData\Local\Programs\Python\Python311\Lib\site-packages\hanlp\layers\embeddings\util_tf.py", line 44, in build_embedding
layer: tf.keras.layers.Embedding = tf.keras.utils.deserialize_keras_object(embeddings)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\win11\AppData\Local\Programs\Python\Python311\Lib\site-packages\keras\src\saving\serialization_lib.py", line 720, in deserialize_keras_object
raise TypeError(
TypeError: <class 'hanlp.layers.embeddings.word2vec_tf.Word2VecEmbeddingTF'> could not be deserialized properly. Please ensure that components that are Python object instances (layers, models, etc.) returned by `get_config()` are explicitly deserialized in the model's `from_config()` method.
config={'class_name': 'HanLP>Word2VecEmbedding', 'config': {'trainable': False, 'embeddings_initializer': 'zero', 'filepath': 'http://downloads.cs.stanford.edu/nlp/data/glove.6B.zip#glove.6B.100d.txt', 'expand_vocab': True, 'lowercase': True, 'normalize': True, 'vocab': <hanlp.common.vocab_tf.VocabTF object at 0x00000172A9695290>}}.
Exception encountered: Error when deserializing class 'Word2VecEmbeddingTF' using config={'trainable': False, 'embeddings_initializer': 'zero', 'filepath': 'http://downloads.cs.stanford.edu/nlp/data/glove.6B.zip#glove.6B.100d.txt', 'expand_vocab': True, 'lowercase': True, 'normalize': True, 'vocab': <hanlp.common.vocab_tf.VocabTF object at 0x00000172A9695290>}.
Exception encountered: 'bool' object has no attribute 'shape'
=================================ERROR LOG ENDS=================================
[x] I've completed this form and searched the web for solutions.
Describe the bug 无法加载英语SDP模型。
Code to reproduce the issue
Describe the current behavior
hanlp无法正常加载英语SDP模型。我卸载了hanlp以及所有依赖,利用
pip install hanlp[full]
重新安装了hanlp,但是问题依旧。Expected behavior
希望可以正常加载英语SDP模型。
System information
Other info / logs