MaartenGr / MaartenGr/BERTopic

Determining optimal range of threshold values in some techniques like outlier reduction or zero shot CLF

Open
#1,401 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

There are many good techniques available in BERTopic which is helpful. However, it would be really great if we can get some conceptual idea about optimizing values of these very crucial parameter values.

For example, we have threshold in outlier reduction. I am using BERTopic for various datasets and they are quite different in number of documents and size of each document. I have one dataset with 34K documents, another has about 1K. I have observed that for first dataset I have to set threshold=0.03 and for another it is threshold=0.30.
How to go about finding approximately good value or range for such parameters?

I have same question for threshold used in Zero shot CLF. By default, its 0.8 but I had to set it to 0.4 to actually see some classification happening.
https://maartengr.github.io/BERTopic/api/representation/zeroshot.html

I am aware that if calculate_probabilities=True is set then we get topic-doc probability matrix but not sure how it can be useful here. Is there any median probability or something like that which we can be used as a reference point for approximate range of threshold value?

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 with the BERTopic reduce_outliers API and the Zero-shot representation documentation linked in the issue. Review how calculate_probabilities exposes the topic-document probability matrix, then determine what guidance or reference for threshold selection could be documented. Done would require an agreed, broadly useful explanation for datasets of different sizes and both threshold uses.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.