MaartenGr / MaartenGr/BERTopic
Guided topic model with pre embedded `seed_topic_list`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.8k
- Forks
- 920
- Avg merge
- 22h 24m
- Merged PRs (30d)
- 5
Description
_This issues follows is about a similar problem addressed in #2014. I can update and merge_
I would like to run a guided topic model with a embedding model that is not supported by BERTopic, I would also like to be able to test some hyperparameters without having to rerun the embeddings. To support this I would like to be able to pass the pre embeded `seed_topic_list`.
What I want to be able to do is something like this:
```python
from bertopic import BERTopic
from sklearn.datasets import fetch_20newsgroups
docs = fetch_20newsgroups(subset='all', remove=('headers', 'footers', 'quotes'))["data"]
seed_topic_list = [["drug", "cancer", "drugs", "doctor"],
["windows", "drive", "dos", "file"],
["space", "launch", "orbit", "lunar"]]
embedded_seed_topic_list = np.random.rand(len(seed_topic_list), 1024)
topic_model = BERTopic(
seed_topic_list=seed_topic_list,
embedded_seed_topic_list = embedded_seed_topic_list,
verbose=True)
topics, probs = topic_model.fit_transform(docs)
```
Like with #2014 I am happy to write up the simple change of adding in another argument so that it can check if the embeddings are arleady present before trying to embed the `seed_topic_list`.
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 at the BERTopic constructor and fit_transform flow shown in the example, then inspect how seed_topic_list is embedded. The issue's expected result is that embedded_seed_topic_list can be supplied and reused while testing hyperparameters, without rerunning those seed embeddings.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100