BERTopic topic_model.reduce_outliers 错误

xyhw6mcr  于 2个月前  发布在  其他
关注(0)|答案(3)|浏览(31)

Hello,
When I use:topic_model.reduce_outliers(topic_model, docs, topics, probabilities=probs,
threshold=0.05, strategy="probabilities")
I met the following bugs May I ask how to solve this ?, it looks like there is an attempt to call embed_images on an object of type SentenceTransformerBackend.:
outlier_embeddings = self.embedding_model.embed_images(outlier_images, verbose=self.verbose)
AttributeError: 'SentenceTransformerBackend' object has no attribute 'embed_images'
Thank you

nfeuvbwi

nfeuvbwi1#

我建议查看 reduce_outliers documentation 。我相信您不应该在 reduce_outliers 中使用 topic_model 作为参数。

ygya80vv

ygya80vv2#

对于 .reduce_outliers(),你只需要传入 docstopics。你不需要再次传入你的模型(这是模型的方法,所以在这种情况下,你的模型实际上是 self)。我认为你传入的其他值是默认值,所以你不需要它们,但如果你想保留它们,应该没问题。
对于第二个错误,你不需要调用 self.embedding_model。术语 self 只存在于示例化类的上下文中,而你可能在这里没有这个类。我猜想,如果你只是移除它,它可能会起作用。

outlier_embeddings = embedding_model.embed_images(outlier_images, verbose=self.verbose)
goucqfw6

goucqfw63#

为了澄清,以下代码片段并不是由OP调用的:
outlier_embeddings = self.embedding_model.embed_images(outlier_images, verbose=self.verbose)
而是在错误地运行以下代码时产生的结果:
topic_model.reduce_outliers(topic_model, docs, topics, probabilities=probs,
threshold=0.05, strategy="probabilities")
换句话说,没有第二个错误,OP遇到的是一个单独的错误。只有一行代码触发了这个错误。这意味着self.embedding_model在任何时候都不会被OP调用,但它会在内部执行。

相关问题