ddangelov / Top2Vec

Top2Vec learns jointly embedded topic, document and word vectors.
BSD 3-Clause "New" or "Revised" License
2.92k stars 374 forks source link

AttributeError: module 'keras._tf_keras.keras' has no attribute '__internal__' #358

Open AbdulmohsenA opened 6 months ago

AbdulmohsenA commented 6 months ago
!pip install top2vec[sentence_encoders]
!pip install tensorflow-probability

from top2vec import Top2Vec
import pandas as pd
import numpy as np

df = pd.read_csv("/content/drive/My Drive/_csvfile")
documents = df['summary'].to_list()
model = Top2Vec(documents)

i get the error: AttributeError: module keras._tf_keras.keras has no attribute __internal__

Google Colab shows the error is in the from top2vec import Top2Vec line

IsrarAwan commented 6 months ago

Install the packages in the following order:

!pip install -q tensorflow==2.15.1
!pip install -q tensorflow_hub==0.12.0
!pip install -q tensorflow_text==2.15.0
!pip install -q top2vec[sentence_transformers]

Keras 3 is incompatible with tensorflow-probability, which is why it's not working. Using the aforementioned versions, top2vec will work and you will not get the AttributeError.

PS. Make sure to delete runtime of Colab before running the cell containing the dependencies above.