KeyBERT icon indicating copy to clipboard operation
KeyBERT copied to clipboard

cannot import name 'KeyBERT' from 'keybert'

Open fz5400 opened this issue 2 years ago • 1 comments

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

fz5400 avatar Jun 06 '23 03:06 fz5400

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.

MaartenGr avatar Jun 09 '23 13:06 MaartenGr