运行代码的时候遇到了报错
ModuleNotFoundError: No module named 'sentence_transformers.model_card'
具体如下:
Traceback (most recent call last):
File "\classifier_utils.py", line 41, in <module>
print(get_follow_up_questions(ClassifierType.BERTOPIC, user_question, hist))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "\classifier_utils.py", line 31, in get_follow_up_questions
bertopic_classifier = BERTopicClassifier()
^^^^^^^^^^^^^^^^^^^^
File "\classifiers\BERTopicClassifier.py", line 13, in __init__
self.model = self._load_model(model_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "\classifiers\BERTopicClassifier.py", line 23, in _load_model
return BERTopic.load(model_path)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "\Lib\site-packages\bertopic\_bertopic.py", line 3386, in load
topic_model = joblib.load(file)
^^^^^^^^^^^^^^^^^
File "\Lib\site-packages\joblib\numpy_pickle.py", line 648, in load
obj = _unpickle(fobj)
^^^^^^^^^^^^^^^
File "\Lib\site-packages\joblib\numpy_pickle.py", line 577, in _unpickle
obj = unpickler.load()
^^^^^^^^^^^^^^^^
File "\Lib\pickle.py", line 1205, in load
dispatch[key[0]](self)
File "\Lib\pickle.py", line 1530, in load_stack_global
self.append(self.find_class(module, name))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "\Lib\pickle.py", line 1572, in find_class
__import__(module, level=0)
ModuleNotFoundError: No module named 'sentence_transformers.model_card'
亲测有效的解决办法👇
报错原因是因为模块缺失,在环境里面更新sentence-transfomers库可以解决
pip install --upgrade bertopic sentence-transformers