'How to fix random seed for BERTopic?

I'd like to fix the random seed from BERTopic library to get reproducible results. Looking at the code of BERTopic I see it uses numpy. Will using np.random.seed(123) be enough? or do I also need to other libraries as random or pytorch as in this question.



Solution 1:[1]

you can fix the random seed

from bertopic import BERTopic
from umap import UMAP

umap_model = UMAP(random_state=42)

topic_model = BERTopic(umap_model=umap_model)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1