Search code examples
pythonnlpbert-language-modellda

Top2Vec Model Failing To Train (Following Simple PyPi Tutorial)


I am trying to follow this tutorial on PyPi (See Example -> Train Model): https://pypi.org/project/top2vec/

Very short amount of code, following it line by line:

from top2vec import Top2Vec
from sklearn.datasets import fetch_20newsgroups

newsgroups = fetch_20newsgroups(subset='all', remove=('headers', 'footers', 'quotes'))

model = Top2Vec(documents=newsgroups.data, speed="learn", workers=8)

I've tried running multiple times on different datasets, yet I keep running into the following error when training/building the model:

UFuncTypeError: ufunc 'correct_alternative_cosine' did not contain a loop with signature matching types <class 'numpy.dtype[float32]'> -> None

Has anyone encountered this error before and if so how have you fixed it? Otherwise, if anyone can run this same code please let me know if you run into the same error.

Thanks


Solution

  • Solved this by moving from a Jupyter notebook in favor for a typical .py file, as well as cloning the library, installing the requirements to a fresh virtualenv and running the setup.py file.