Skip to content

ImportError: cannot import name 'StaticEmbedding' from 'sentence_transformers.models' #2331

@stevetracvc

Description

@stevetracvc

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Desribe the bug

Title pretty much says it all.

BERTopic/bertopic/backend/_sentencetransformers.py:4
    from sentence_transformers.models import StaticEmbedding

Looks like this is an issue with versions. SentenceTransformer didn't add Model2Vec till
#2245
but there's no requirement that the new version of SentenceTransformer is installed.

I'll submit a PR to fix this, but I don't know what solution you'd prefer. I think the best option is to move that import from line 4 to line 58, since it appears that's the only place it's needed. I'll make a PR and test it.

Reproduction

from bertopic.backend._sentencetransformers import SentenceTransformerBackend

BERTopic Version

v0.17.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions