MaartenGr / MaartenGr/BERTopic

Zero Shot Topic ordering

Open
#2,365 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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 predefined the zero shot topic list, but the ordering of the topics is not the same as the list i provided:

```python
zeroshot_topic_list = [
'Technology & Science',
'Arts Culture',
'Business',
'International',
'Geo Politics',
'Health & Wellness',
'Sports',
'Opinion & Editorial',
'Education',
'Environment',
]

topic_model = BERTopic(
language='english',
embedding_model="thenlper/gte-large",
min_topic_size=15,
zeroshot_topic_list=zeroshot_topic_list,
zeroshot_min_similarity=0,
calculate_probabilities=True,
representation_model=KeyBERTInspired()
)
topics, props = topic_model.fit_transform(docs)
```

Image

### Reproduction

```python
from bertopic import BERTopic

zeroshot_topic_list = [
'Technology & Science',
'Arts Culture',
'Business',
'International',
'Geo Politics',
'Health & Wellness',
'Sports',
'Opinion & Editorial',
'Education',
'Environment',
]

topic_model = BERTopic(
language='english',
embedding_model="thenlper/gte-large",
min_topic_size=15,
zeroshot_topic_list=zeroshot_topic_list,
zeroshot_min_similarity=0,
calculate_probabilities=False,
representation_model=KeyBERTInspired()
)
topics, props = topic_model.fit_transform(docs)
```

### BERTopic Version

0.17.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided BERTopic reproduction with the zero-shot topic list and inspect how fit_transform handles zero-shot topics and their returned ordering. The issue is resolved when the resulting topic ordering follows the supplied zeroshot_topic_list; the payload does not name a source file or test.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.