ModuleNotFoundError: No module named ‘sentence_transformers.model_card‘

运行代码的时候遇到了报错

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值