MaartenGr / MaartenGr/BERTopic

should we reduce the dimensionality of topic_model.topic_embeddings_ ?

Open
#1,959 2 comments 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

Dear Creator of the amazing BERTopic

I want to perform cosine similarity of the topic_embeddings to a list of labels. I found it to perform better than zeroshot (and faster !) for my use case. However, the embeddings in topic_model.topic_embeddings_ are 384 dimensional vectors, ie their dimension is not reduced using hdbscan. To my understanding, the cosine similarity could suffer from the curse of dimensionality because of that. Actually, ploting the max cosine similarity to my list of labels might suggest that, making most topics cosine similar to my labels to 0. 55 :
![cosine score webpage](https://github.com/MaartenGr/BERTopic/assets/100510107/9ab4a718-6680-475c-a602-acb8f29f634b)

Should I add a dimensionality reduction step ? would it be possible to use directly the reduced embeddings for the topic_model ?

Again thanks for your work

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 tracing how BERTopic produces and stores topic_embeddings_, then compare that path with the HDBSCAN dimensionality-reduction step mentioned in the issue. Determine whether reduced embeddings can be used for cosine similarity without changing topic behavior; completion would require a clear design decision and validation of the resulting similarity scores.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Feature
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.