MaartenGr / MaartenGr/BERTopic
How to get consistent topics and consistent visualizations
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.8k
- Forks
- 920
- Avg merge
- 22h 24m
- Merged PRs (30d)
- 5
Description
I ran my exact same code in two different Google Collab notebooks.
In my first iteration, after running `topic_model.get_topics()` I had 6 topics, and topic 0 looked like:
0: [('as', 0.08563909021495479),
('at', 0.06317604494537135),
('going', 0.060597216092035056),
('getting', 0.060597216092035056),
('pits', 0.058612037038276894),
('right', 0.058612037038276894),
('to', 0.05765285731688925),
('lot', 0.05632741767548143),
('pim', 0.05632741767548143),
In my second iteration, after running `topic_model.get_topics()` I had 5 topics, and topic 0 looked like:
0: [('the', 0.06550073139765457),
('to', 0.05867363929704857),
('am', 0.055053057163662246),
('feel', 0.05374010219277422),
('course', 0.05296712849238285),
('pi', 0.051050949320372865),
('with', 0.046059889942741156),
('im', 0.04497906524403958),
('class', 0.04261441618155628),
('doing', 0.04125789956670219)]
And my visualizations from running `topic_model.visualize_topics()` looked different between my two iterations.
1) I originally imagined that I could find the seeds along each step of the BERTopic process (the embedding, UMAP, HDBSCAN, or c-tf-idf/CountVectorizer or topic reduction/top2veC processes) but I have no idea how to go about this. I really want to do this because I liked the results from my first iteration
2) On top of not knowing how to get the seeds along each step of the BERTopic process, I don't know how to set seeds at each process
3) I'm not sure which of the steps in the BERTopic process might be introducing the elements of randomness causing my dissimilarities
How can I resolve my issue of consistency, and can someone enlighten me about which steps are causing inconsistencies in my results?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the two Google Colab runs using the reported get_topics() and visualize_topics() calls, then inspect the embedding, UMAP, HDBSCAN, c-TF-IDF/CountVectorizer, and topic-reduction/top2veC stages for differing seeds. Done means identifying which stage causes the variation and explaining how to obtain consistent topics and visualizations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100