MaartenGr/BERTopic

AttributeError: 'TextGeneration' object has no attribute 'random_state'

Closed this issue · 3 comments

Hello,

I followed the amazing tutorial from https://www.youtube.com/watch?v=5a5Dfft-rWc. I ran it smoothly, until I got to the following chunk where we specify our different representations:

from bertopic.representation import KeyBERTInspired, MaximalMarginalRelevance, TextGeneration

# KeyBERT
keybert = KeyBERTInspired()

# MMR
mmr = MaximalMarginalRelevance(diversity=0.3)

# Text generation with Llama 2
llama2 = TextGeneration(generator, prompt=prompt)

# All representation models
representation_model = {
    "KeyBERT": keybert,
    "Llama2": llama2,
    "MMR": mmr,
}
representation_model

The result was

AttributeError: 'TextGeneration' object has no attribute 'random_state'

I looked for it in the code, it looks like there is a random_state parameter that enters as a default to 'TextGeneration', even though it takes no such argument and hence the error arises.

Thanks!

And PS - THANK YOU SO MUCH for the amazing work you did. You're a life-saver.

Thank you for your kind words!

I just recently also ran into this issue. Apparently, scikit-learn had an update that made it necessary to assign parameters to the class itself (which I had completely forgotten!).

However, that should now be fixed in the main branch. So if you install BERTopic from the latest commit, it should work for you.

Perfect, it worked, thanks! Installing from Git directly:

!pip install git+https://github.com/MaartenGr/BERTopic/