#2531·BERTopic

Topic aspects are not updated when merging topics and the model uses a custom vectorizer

Author: aymanmhCreated Aug 12, 2026Updated Aug 12, 2026
Labelsbug

Have you searched existing issues?

  • I have searched and found no existing issues

Desribe the bug

If the update_topics function is called with a custom vectorizer, any topic merging afterwards will not update the aspects of the topic representations, causing them to refer to the old topic, the following is before and after calling merge

Before calling merge (aspects are correctly mapped to the topics)

Image

after merging topics 6 and 7, the newly merged topic now topic 5, has Aspect1 and Aspect2 of the pre-merge topic 5, and every topic after 5 has the wrong aspects, still referring the old topic, displaced by one in this case (since one topic was gone)

Image

When not using a custom vectorizer merging works fine as expected.

Reproduction

python
from bertopic import BERTopic
from sklearn.datasets import fetch_20newsgroups

docs = fetch_20newsgroups(subset='all',  remove=('headers', 'footers', 'quotes'))['data']

main_representation_model = KeyBERTInspired()
aspect1_representation_model = PartOfSpeech("en_core_web_sm")
aspect2_representation_model = MaximalMarginalRelevance(diversity=0.3)

representation_model = {
   "Main": main_representation_model,
   "Aspect1":  aspect1_representation_model,
   "Aspect2":  aspect2_representation_model
}

topic_model = BERTopic(representation_model=representation_model)

topics, probs = topic_model.fit_transform(docs)

vectorizer_model = CountVectorizer(stop_words="english", ngram_range=(1, 3), min_df=15)
topic_model.update_topics(docs, vectorizer_model=vectorizer_model)

topic_model.merge_topics(docs, [6,7])

topic_model.get_topic_info()[1:12]

BERTopic Version

0.17.4