Esteban Echandi
Esteban Echandi

Reputation: 31

Python import spacy sentence bert

I'm trying to import import spacy_sentence_bertand run the following code in python.

I installed conda install -c conda-forge spacy-transformers on the anaconda prompt.

import spacy_sentence_bert
nlp = spacy_sentence_bert.load_model('en_stsb_bert_large')

The error that I'm receiving is the following:

ModuleNotFoundError: No module named 'spacy_sentence_bert'

I had this working, however, I had to uninstall Python recently due to another error and now its not working.

Any help will be appreciated, I'm not so well-versed in Python.

Im using Python 3.9.12 downloaded thru Anaconda with Spyder IDE.

Upvotes: 2

Views: 554

Answers (1)

polm23
polm23

Reputation: 15623

You need to install spacy-sentence-bert, either with pip install spacy-sentence-bert or the conda equivalent. (Mixing conda and pip often works, but can sometimes result in strange errors.)

spacy-transformers is a separate package, and is for wrapping Transformers in spaCy in general. It's kind of confusing, but sentence-transformers is also a separate package, and spacy-sentence-bert is a wrapper for that package.

Upvotes: 1

Related Questions