Inferensys

Glossary

Intertopic Distance Map

A visualization component of pyLDAvis that uses multidimensional scaling to project topic centroids into two dimensions, allowing users to assess topic overlap and distinctness.
Developer demonstrating multi-agent tool use, agent tool selection interface on laptop, casual tech demo moment.
TOPIC MODEL VISUALIZATION

What is an Intertopic Distance Map?

An intertopic distance map is a two-dimensional visualization component of pyLDAvis that projects topic centroids using multidimensional scaling, enabling users to assess topic overlap, distinctness, and semantic relationships within a fitted topic model.

An intertopic distance map is a dimensionality-reduction visualization that projects the high-dimensional topic centroids of a model like LDA onto a 2D plane using multidimensional scaling (MDS). Each bubble represents a topic, with its size proportional to the topic's prevalence in the corpus. The spatial distances between bubbles approximate the semantic similarity between topics, allowing rapid assessment of model quality.

Developed as part of the pyLDAvis library, the map uses the Jensen-Shannon divergence between topic-word distributions to compute the intertopic distance matrix before projection. Overlapping or closely clustered bubbles indicate potential topic redundancy, while well-separated, distinct bubbles suggest a model with high topic diversity. This visual diagnostic helps data scientists tune the number of topics (K) hyperparameter.

VISUALIZING LATENT SPACES

Key Features of the Intertopic Distance Map

The Intertopic Distance Map is the primary visualization component of pyLDAvis, projecting high-dimensional topic centroids into a 2D plane to allow immediate assessment of topic overlap, distinctness, and semantic relationships.

01

Multidimensional Scaling (MDS) Projection

The map uses Principal Coordinate Analysis (PCoA) to project topic-topic distance matrices into two dimensions. The distance between any two topic centroids is calculated using Jensen-Shannon divergence between their word distributions. This preserves the original high-dimensional inter-topic relationships as faithfully as possible in a 2D plane, allowing you to visually identify which topics are semantically proximal and which are distinct.

02

Circle Area and Topic Prevalence

Each topic is represented as a circle whose area is proportional to the marginal topic prevalence in the corpus. Larger circles indicate topics that appear more frequently across documents. This visual encoding provides an immediate, intuitive sense of which themes dominate the corpus without needing to inspect numerical tables. A large, isolated circle suggests a dominant, well-defined theme; a small circle overlapping others suggests a niche or less coherent topic.

03

Assessing Topic Overlap and Distinctness

The spatial proximity of circles directly reflects semantic similarity. Overlapping circles indicate topics that share many high-probability words and may be redundant. Isolated circles represent highly distinct, interpretable topics. This visual diagnostic helps determine if the chosen Number of Topics (K) is appropriate: excessive overlap suggests K is too high, while a few massive circles suggest K is too low.

04

Salient Terms and Relevance Metric

Clicking a topic circle reveals a horizontal bar chart of its salient terms, ranked by a tunable relevance metric (λ). This metric balances a term's frequency within the topic against its exclusivity:

  • λ = 1: Ranks by purely by probability within the topic (frequent, potentially generic words)
  • λ = 0: Ranks by lift over the corpus-wide background frequency (highly exclusive, potentially rare words) Adjusting λ helps analysts interpret what makes a topic unique.
05

Interactivity and Diagnostic Workflow

The map is fully interactive, enabling a systematic diagnostic workflow:

  • Hover over circles to see the top terms for each topic instantly
  • Click a circle to lock the term bar chart and inspect word distributions in detail
  • Identify overlapping clusters that may indicate the need to merge topics or reduce K
  • Validate that isolated topics correspond to semantically coherent themes by examining their top-ranked exclusive terms at λ ≈ 0.3
06

Relationship to Topic Coherence

While the Intertopic Distance Map provides a qualitative visual assessment, it complements quantitative metrics like Topic Coherence and C_V Coherence. A well-structured map with distinct, non-overlapping circles typically correlates with high coherence scores. Conversely, a map showing a diffuse cloud of overlapping small circles often indicates low semantic interpretability, prompting a re-evaluation of preprocessing steps, the number of topics, or the choice of model hyperparameters like Alpha and Beta.

INTERTOPIC DISTANCE MAP VISUALIZATION

Frequently Asked Questions

Explore the most common questions about interpreting and generating intertopic distance maps, the core visualization component of pyLDAvis used to assess topic model quality through multidimensional scaling.

An intertopic distance map is a two-dimensional visualization that projects the centroids of discovered topics onto a plane using multidimensional scaling (MDS) , allowing analysts to assess topic overlap, distinctness, and semantic relationships. The map is generated by first computing the Jensen-Shannon divergence between every pair of topic-word distributions, creating a distance matrix that quantifies how dissimilar topics are from one another. Principal component analysis (PCA) is then used to initialize the MDS projection, which iteratively optimizes the 2D coordinates to preserve the original high-dimensional distances as faithfully as possible. Each topic is represented as a circle whose area is proportional to its prevalence in the corpus, and the distance between any two circles reflects their semantic similarity—topics that share many high-probability words will appear closer together. This visualization is the default view in pyLDAvis, an interactive library designed by Carson Sievert and Kenny Shirley to aid in interpreting Latent Dirichlet Allocation (LDA) models.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.