MaartenGr / KeyBERT

Minimal keyword extraction with BERT
https://MaartenGr.github.io/KeyBERT/
MIT License
3.31k stars 337 forks source link

cannot import name 'KeyBERT' from 'keybert' #174

Open fz5400 opened 1 year ago

fz5400 commented 1 year ago

Hi,

I am using KeyBERT for the first time. During my attempt, I encountered the following problems:

截屏2023-06-06 11 05 03

Here is the code that I used for: ‘’‘ from keybert import KeyBERT

doc = """ Supervised learning is the machine learning task of learning a function that maps an input to an output based on example input-output pairs. It infers a function from labeled training data consisting of a set of training examples. In supervised learning, each example is a pair consisting of an input object (typically a vector) and a desired output value (also called the supervisory signal). A supervised learning algorithm analyzes the training data and produces an inferred function, which can be used for mapping new examples. An optimal scenario will allow for the algorithm to correctly determine the class labels for unseen instances. This requires the learning algorithm to generalize from the training data to unseen situations in a 'reasonable' way (see inductive bias). """ kw_model = KeyBERT() keywords = kw_model.extract_keywords(doc) ’‘’

Does anyone know how to fix this? QWQ

MaartenGr commented 1 year ago

Rename your keybert.py to something else and your issue should be fixed. You are trying to import KeyBERT from your keybert.py file which is not something you should do.