MaartenGr / MaartenGr/BERTopic

BERTopic n-gram words are not adjacent to each other

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

After setting the ngram_range=(2,2), the trained BERTopic model generates topics with 2-gram phrases such as Topic_1: {"Model Router", "Network Setup", etc}, but the individual words of each 2-gram are not adjacent to each other within the document and they are far away form each other. It seems that the BERTopic model is not considering 2-gram at all. Is there any way to make sure that the individual words in the 2-gram phrases of each topic are not far away from each other within the related documents? I don't want BERTopic considers "Modem Router" as a 2-gram if there is no sentence in the whole document having "Modem" and "Router" words next to each other

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 reproducing the reported BERTopic behavior with ngram_range=(2,2) and inspect how the trained model extracts topic phrases from related documents. No source file or test is named in the issue. Done should mean that a two-word topic phrase is formed only when its words occur adjacently in the document.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.