Explainable NMF Topic Model

Machine Learning
Introduced by
Lee, D. D. & Seung, H. S. (NMF); XAI layer attributed to community practice post-2016
Year
2001 (NMF); XAI integration ~2017–present
Type
Interpretable unsupervised topic model
Family
Deep learning / NLP / CV

What does it do?

Explainable NMF topic modeling is a workflow that applies Non-negative Matrix Factorization (NMF) to a document-term matrix and adds quality and interpretability checks to the resulting topics.

NMF splits the matrix into non-negative word-topic and document-topic factors. The added steps estimate topic quality with coherence scores and report how strongly individual words and, where a downstream model is used, topic features drive its predictions. The workflow combines standard tools rather than forming a single standardized algorithm. It suits settings where topic labels must be checked and justified by people, not only generated.

The intuition behind the method

NMF factors a document-term matrix into two non-negative matrices: one gives each topic as a weighted mixture of words, and the other gives each document as a mixture of topics. Because no value can be negative, every word contributes to a topic by adding to it, and no word is cancelled out by a negative loading. This can make the topic-word profiles easier to read than factors from methods that allow negative values. The explainability layer then asks two different questions: whether the topics are coherent (do their top words co-occur in the corpus?) and, if a downstream model uses the topics, which topic features push its predictions.

History

Non-negative matrix factorization is associated with Lee and Seung, whose 2001 paper on NMF algorithms, cited on this page, introduced multiplicative update procedures for the reconstruction objectives. In topic modeling, NMF serves as a deterministic, non-probabilistic alternative to probabilistic models such as LDA. Combining NMF topics with coherence scoring and feature attribution is a more recent practice rather than a single named method, and no single originating source for this combined workflow is identified.

When to use it

Choose this method when you need to find latent themes in a text corpus and must justify them to reviewers, stakeholders, or regulators who expect to inspect the topic-word profiles directly. It suits settings where the topics will be checked by domain experts and where a deterministic, non-negative factorization is preferred over a sampling-based probabilistic model. Be cautious with a very small corpus. How many documents and terms are enough depends on vocabulary size and document length, so check whether the factors and coherence scores stay stable across restarts before relying on them. It is also a poor choice when word order, syntax, or sense distinctions matter, since the bag-of-words input discards them. When a full probabilistic account of topic uncertainty is needed, LDA or a neural topic model with explicit uncertainty estimates is the better fit.

Limitations and considerations

  • The number of topics k must be fixed before the factorization. A value that is too large splits one theme into near-duplicate topics, and one that is too small merges distinct themes.
  • The objective is non-convex, so the factors depend on the initialization. Several random restarts are needed to check that the topics are stable.
  • The bag-of-words input discards word order and context, so topics cannot separate different senses of the same word or capture negation.
  • Coherence measures reward words that co-occur frequently in the corpus. A topic can score well and still be a coherent but unhelpful grouping of words.
  • SHAP and LIME attributions explain a downstream model rather than the factorization, and they add computation and interpretation effort.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Non-negativity makes each word's weight in a topic an additive, positive contribution, so top-word lists can be read without negative loadings offsetting them.
  • Given the same initialization and update settings, the factorization is deterministic, so a rerun reproduces the same factors. This differs from the sampling variability of LDA.
  • The document loadings in W are non-negative and can be used as interpretable features in a downstream classifier.
  • Coherence scores (C_v, NPMI) give a quantitative basis for comparing candidate values of k and for reporting topic quality.
  • The document-term matrix is sparse, so sparse matrix storage and solvers keep memory use manageable for large vocabularies.

Applications

  • Thematic analysis of large document collections in social science and policy research.
  • Content analysis in communication studies where topic labels must be reproducible and open to inspection.
  • Literature mining in biomedicine, where domain experts check topic labels before they are used.
  • Analysis of customer feedback and survey responses, with topic summaries intended for non-technical stakeholders.
  • Feature construction for downstream text classifiers that need interpretable topic loadings as inputs.

How it works

How it works

1

The corpus is preprocessed (tokenization, stopword removal, lemmatization) and converted into a document-term matrix using bag-of-words counts or TF-IDF weights. The weighting choice changes which word patterns the factorization can recover, so preprocessing and weighting should be recorded with the results.

2

NMF approximates the document-term matrix V (documents by terms) with two non-negative factors, W (documents by topics) and H (topics by terms), by minimizing a reconstruction loss under non-negativity constraints. The loss is typically the Frobenius norm or the KL divergence. The number of topics k is a fixed hyperparameter, so it must be chosen before the factorization is run.

Formula
V \approx W H, \quad W, H \geq 0
3

Each row of H is the word profile of one topic, and the highest-weighted words in that row serve as the topic's label. Each row of W gives the topic weights for one document. Because the factors are non-negative, each word's weight in a topic is a positive contribution to that topic.

4

Coherence measures such as C_v and NPMI estimate how well each topic's top words co-occur in the corpus, and are used to judge topic quality and to compare candidate values of k. Word-contribution rankings order the terms within each topic by weight. If the topics feed a downstream classifier, SHAP or LIME can attribute that classifier's predictions to topic features; these attributions explain the downstream model, not the factorization itself. Because these components are standard tools combined in one workflow, the coherence settings, including the reference corpus used for co-occurrence, should be reported with the results.

5

Report coherence (C_v, NPMI), topic diversity, reconstruction error, and, where topics feed a classifier, downstream task performance. Repeat the factorization from several random initializations and check whether the topics are stable, since the topics should not be an artefact of one starting point.

Common pitfalls

  • Choosing one value of k and accepting its topics without comparing coherence across a range of candidate values.
  • Skipping stopword removal, so function words dominate the top-word lists of several topics.
  • Reporting only the top words of each topic, without a coherence score or a stability check across restarts.
  • Treating low reconstruction error as evidence of meaningful topics; a closer fit to V does not guarantee more interpretable topics.
  • Changing between raw counts and TF-IDF weighting across runs and then comparing the results as if they were equivalent.
  • Running SHAP or LIME on topic loadings before confirming that the topics are stable across restarts.

Frequently asked questions

How is Explainable NMF different from standard NMF topic modeling?

Standard NMF reports topic-word profiles and document-topic loadings. Explainable NMF, as described here, adds coherence-based checks of topics, word-contribution rankings and, when a downstream model is present, SHAP or LIME attributions that show which topic features influence its predictions. It is a combination of these standard steps rather than a separate algorithm.

How do I choose the number of topics k?

Fit the model for several candidate values of k, compute a coherence score such as C_v or NPMI for each, and compare them. Combine the coherence comparison with inspection of the top words and with a check of whether the topics are stable across restarts.

Is NMF better than LDA for explainability?

NMF's non-negative, additive factors are often easier to read directly than LDA's Dirichlet-based distributions, and NMF does not require sampling from a generative model. LDA, however, gives a principled probabilistic account of uncertainty over topic mixtures, which NMF does not provide.

What coherence metric should I report?

C_v and NPMI are commonly reported coherence measures. Report both with the chosen k, the preprocessing steps, the weighting scheme, and the reference corpus used to compute co-occurrence, so that the results can be reproduced.

Can I use TF-IDF instead of raw counts?

Yes. TF-IDF downweights terms that appear in most documents, which often produces more distinctive topic-word profiles. The trade-off is that the reconstructed matrix no longer represents raw term frequencies, so reconstruction error is harder to interpret.

Related methods

Sources

  1. Lee, D. D., & Seung, H. S. (2001). Algorithms for non-negative matrix factorization. Advances in Neural Information Processing Systems, 13, 556–562.

    Open publication reference
  2. Non-negative matrix factorization. Wikipedia.

    Open publication reference