MaartenGr / MaartenGr/BERTopic
Changing number of topics
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.8k
- Forks
- 920
- Avg merge
- 22h 24m
- Merged PRs (30d)
- 5
Description
### Have you searched existing issues? 🔎
- [x] I have searched and found no existing issues
### Desribe the bug
I have been running BERTopic on a dataset for the Chinese language. I see every time I run the model, I get either two topics or around 315 topics. I'm not sure what is causing this drastic change and which result is acceptable.
### Reproduction
```python
from bertopic import BERTopic
device = 'cuda' if torch.cuda.is_available() else 'cpu'
sentence_model = SentenceTransformer('paraphrase-multilingual-MiniLM-L12-v2', device=device)
umap_model = umap.UMAP(n_neighbors=15, n_components=5, metric='cosine')
topic_model = BERTopic(embedding_model=sentence_model, umap_model=umap_model, language="multilingual")
topics, _ = topic_model.fit_transform(texts)
topic_model.get_topic_info()
# either two or around 315 topics
```
### BERTopic Version
0.16.4
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
Start with the BERTopic fit_transform call and the configured UMAP model in the reproduction, then inspect get_topic_info() across repeated runs. Reproduce the two-topic and approximately 315-topic outcomes with the same inputs and determine which configuration or behavior causes the variation. Done means identifying the source of the discrepancy and documenting which result is expected.
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