Interpreting Topic Models in Byte-Pair Encoding Space

Jia Peng Lim, Hady Wirawan LauwCOLING 2025

TL;DR

This paper tackles the challenge of interpreting topic models when using Byte-Pair Encoding (BPE) tokens, which are sub-word units common in Large Language Models (LLMs). They propose a novel, model-agnostic method to recover meaningful words from BPE token distributions, enabling the use of existing topic coherence evaluation metrics and demonstrating that BPE-based topic models can indeed produce coherent topics.

What Problem Does This Paper Address?

Large Language Models (LLMs) increasingly rely on Byte-Pair Encoding (BPE) to tokenize text. BPE breaks down words into smaller, sub-word units, which is efficient for handling vocabulary size and out-of-vocabulary words. However, this presents a significant challenge for traditional topic modeling. Topic models typically operate on whole words and use coherence metrics that assume these words are semantically meaningful units. When applied to BPE tokens, which are often just parts of words, these metrics become incompatible, making it difficult to evaluate and interpret the topics discovered. This paper aims to bridge this gap by developing a way to interpret topic models trained on BPE tokens, thus opening up new avenues for research in this area.

Methods

The core of the paper's contribution lies in its proposed method for recovering valid words from BPE token distributions. They frame this as a "word recovery problem" and present a model-agnostic, training-free approach. The process involves:

  1. Topic-Token Distribution: Obtaining the probability distribution of BPE tokens for each topic from a trained topic model.
  2. Word Recovery as Ranking: For a given topic, they recover candidate words from a predefined vocabulary. This is done by assigning a ranking score to each word based on how its constituent BPE tokens contribute to the topic's distribution.
  3. Ranking Score Calculation: Several methods are proposed to calculate this ranking score, including:
  4. Summation: Aggregating the probabilities of BPE tokens belonging to a word.
  5. Arithmetic Mean: Penalizing longer words to avoid bias.
  6. Geometric Mean: Mitigating vanishing values from small token probabilities.
  7. Harmonic Mean: Accounting for the spread of token probabilities, giving more importance to less frequent but potentially more informative tokens.
  8. Shortlisting Candidates: To manage computational complexity, they introduce a candidate shortlisting strategy, focusing on BPE tokens that are most prominent in a topic.
  9. Evaluation: The recovered word sets are then evaluated using standard topic coherence metrics like Normalized Pointwise Mutual Information (NPMI) and Topic Uniqueness (TU).

Datasets

The authors utilized four large, diverse corpora for their experiments:

  • arXiv Dataset: Abstracts from scientific research papers.
  • UN General Debate corpus: Statements on geopolitical issues from the United Nations.
  • Yahoo! Answers: Best answers from curated categories.
  • Yelp Review Full: Reviews from businesses in metropolitan locations.

These corpora were processed and tokenized using LLaMA's BPE tokenizer. The evaluation also leveraged Wikipedia corpus statistics for NPMI calculations.

Key Insights and Ideas

  • BPE Tokens as a "Meta-Language": The paper posits that BPE tokens, due to their prevalence in LLMs, can be considered a new "meta-language" for NLP applications, necessitating new interpretation methods.
  • Word Recovery as a Ranking Problem: Reframing the interpretation of BPE-based topics as a word recovery and ranking task is a key conceptual shift.
  • Harmonic Mean for Coherence: The Harmonic Mean emerged as a particularly effective method for calculating word ranking scores, leading to more coherent topic representations.
  • Shortlisting is Effective: The proposed shortlisting strategy significantly reduces the computational burden without substantially compromising the quality of recovered topics.
  • BPE Topics Can Be Coherent: A major insight is that topic models trained on BPE tokens, when interpreted using their proposed method, can yield coherent topics comparable to those trained on full words.

Key Results

  • Coherent Topic Recovery: The proposed method, particularly using Harmonic Mean and a shortlisted set of candidate words, successfully recovers coherent topic representations from BPE token distributions.
  • NPMI Scores: The recovered topics from BPE-tokenized corpora (Mb) achieved NPMI scores comparable to, and in some cases even exceeding, those from models trained on original vocabularies (Mo), suggesting good interpretability.
  • User Study Validation: A user study indicated that participants found the recovered topics from BPE-tokenized models to be coherent, with a high percentage of positive responses.
  • Efficiency: The shortlisting approach reduced the vocabulary space considered by less than 1%, demonstrating computational efficiency.
  • Analogy to Original Topics: Similarity analysis showed that topics recovered from BPE tokens are analogous to those learned from the original vocabulary, even when using different topic models.

Limitations and Future Work

  • Tokenizer Choice: The study primarily used LLaMA's BPE tokenizer. The authors acknowledge that results might vary with different tokenizers (e.g., GPT-2's BPE tokenizer), which could have larger token spaces.
  • Vocabulary Selection: The recovery process relies on selecting a vocabulary space. If only rare words are selected, interpretability might be compromised.
  • Language Specificity: The corpora and evaluation were primarily English-based, with some non-English documents observed. Further research is needed for non-English corpora.
  • Small Corpora: Modeling small corpora with BPE might not always be beneficial, as neural topic models sometimes collapsed to fewer topics.
  • Future Work: The authors suggest incorporating topic modeling methodologies to control LLM outputs, moving beyond traditional prompting strategies. They also propose exploring more sophisticated word recovery and shortlisting techniques.

Summary updated

BibTeX
@inproceedings{lim2025interpreting,
  author = {Jia Peng Lim and Hady Wirawan Lauw},
  title = {{Interpreting Topic Models in Byte-Pair Encoding Space}},
  booktitle = {International Conference on Computational Linguistics},
  year = {2025},
  url = {https://openreview.net/forum?id=vp64UcJcYK},
}
Figure