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.
Asked
Active
Viewed 2,025 times
5

RM-
- 986
- 1
- 13
- 30
1 Answers
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)

sxyxxn
- 13
- 7
-
This doesn't work. – Ethan Chen Jun 24 '22 at 18:13
-
The example above is de-facto mentioned in the [https://maartengr.github.io/BERTopic/faq.html#why-are-the-results-not-consistent-between-runs](official documentation) – PROrock Jun 28 '22 at 16:29