MaartenGr / MaartenGr/BERTopic

'Reduce Outliers' does not work when using zero shot topics

Open
#1,771 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7.8k
Forks
920
Avg merge
22h 24m
Merged PRs (30d)
5

Description

Hi Maarten - first, many thanks for the amazing library and continued updates! Just wanted to point out that when using zero shot topics, the outlier topic ID changes from -1 to some positive integer depending on however many zero shot topics the model accepts. This causes issues with the 'reduce outliers' function which looks for outliers using topic ID == -1. Please see attached screenshot. In this case, my outliers have a topic ID of '4' instead of '-1' because of which the reduce outliers function is not able to identify them. Thanks!

![Screenshot 2024-01-26 at 1 56 07 PM](https://github.com/MaartenGr/BERTopic/assets/36107579/224119d5-dc67-4549-bc24-e3ccc025cf58)

This is the code snippet from the reduce outliers function:

# Reduce outliers by finding the most similar topic embeddings
elif strategy.lower() == "embeddings":
if self.embedding_model is None and embeddings is None:
raise ValueError("To use this strategy, you will need to pass a model to `embedding_model`"
"when instantiating BERTopic.")
outlier_ids = [index for index, topic in enumerate(topics) if topic == -1]

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 at the reduce outliers function, especially the embeddings strategy shown in the issue, and trace how zero-shot topic IDs are assigned. Reproduce the case where outliers receive a positive ID, then verify that the reduce outliers behavior identifies and processes those documents correctly.

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
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.