NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Scaled-up Discovery of Latent Concepts in Deep NLP Models

Majd Hawasly, Fahim Dalvi, Nadir Durrani · OpenReview

Abstract

Pre-trained language models (pLMs) learn intricate patterns and contextual dependencies via unsupervised learning on vast text data, driving breakthroughs across NLP tasks. Despite these achievements, these models remain black boxes, necessitating research into understanding their decision-making processes. Recent studies explore representation analysis by clustering latent spaces within pre-trained models. However, these approaches are limited in terms of scalability and the scope of interpretation because of high computation costs of clustering algorithms. This study focuses on comparing clustering algorithms for the purpose of scaling encoded concept discovery of representations from pLMs. Specifically, we compare three algorithms in their capacity to unveil the encoded concepts through their alignment to human-defined ontologies: Agglomerative Hierarchical Clustering, Leaders Algorithm, and K-Means Clustering. Our results show that K-Means has the potential to scale to very large datasets, allowing rich latent concept discovery, both on the word and phrase level.

Introduction

Deep learning models for Natural Language Processing (NLP) are notoriously opaque. While they perform tasks with incredible accuracy, understanding how they represent linguistic concepts—such as "past-tense verbs" or "proper nouns"—remains a significant challenge. Previous research attempted to identify these concepts by clustering contextualized embeddings produced by models like BERT. However, these efforts were largely constrained by the use of Agglomerative Hierarchical Clustering (AHC), which has a quadratic computational cost ($O(N^2)$). This scalability bottleneck limited researchers to small datasets, providing only a narrow view of a model's internal knowledge. This paper addresses this limitation by exploring scalable clustering methods to discover latent concepts across millions of tokens in massive models like Llama-2.

Methodology

The researchers evaluated three clustering strategies to balance computational efficiency and concept quality:

  1. Agglomerative Hierarchical Clustering (AHC): The computationally expensive baseline.
  2. Leaders Algorithm: A two-stage approach that reduces the dataset into "leaders" before applying AHC.
  3. K-Means Clustering: A linear-time algorithm ($O(N)$) that offers significantly higher efficiency.
Overview of the latent concept discovery pipeline, including embedding extraction, clustering, and evaluation via alignment and coverage metrics.

To evaluate the quality of the discovered clusters, two metrics were introduced:

  • Alignment: The degree to which a cluster corresponds to a known human-defined concept (e.g., the percentage of tokens in a cluster that are nouns).
  • Coverage: The proportion of known human concepts successfully captured by at least one cluster.

The study utilized several linguistic benchmarks, including the Penn Treebank (PTB) for POS tagging, the CCG TreeBank for syntactic categories, the Parallel Meaning Bank (PMB) for semantic tagging, and the Stanford Sentiment Treebank (SST) for phrasal-level analysis.

Results and Discussion

The findings suggest that K-Means is a highly effective tool for latent concept discovery. Contrary to the assumption that complex hierarchical models are necessary for linguistic nuance, K-Means outperformed AHC in both alignment and coverage. The ability to process larger datasets proved more critical than the complexity of the clustering algorithm itself. For instance, scaling the data for Llama-2-7B improved the recovery of linguistic structure by 26% compared to smaller subsets.

Examples of discovered latent concepts across lexical, morphological, syntactic, and semantic levels, demonstrating the model's ability to group related linguistic units.

Key results include:

  • Efficiency Gains: K-Means reduced memory usage from 450GB (for AHC) to just 13GB for the same task.
  • Quality Improvement: In layer 12 of BERT, K-Means achieved an alignment score of 60.2% for POS tags, compared to 47.8% for AHC.
  • Redundancy: BERT was found to store linguistic concepts much more redundantly than RoBERTa or XLM-R, suggesting its internal "filing system" is less efficient than its successors.
  • Phrasal Discovery: The speed of K-Means allowed the authors to move beyond single words to cluster multi-word phrases, revealing that models naturally group phrases with similar sentiments.

Conclusion

While the proposed metrics rely on human-defined ontologies—potentially missing "alien" concepts useful to the model but unknown to humans—this work demonstrates a scalable path toward documenting the internal knowledge of LLMs. Future research aims to use these scalable techniques to explore even more complex linguistic constructs and to use LLMs themselves to label the discovered clusters, moving toward a fully automated way of documenting the internal knowledge base of any new AI model.

Summary updated

BibTeX
@inproceedings{hawasly2024scaled,
  author = {Majd Hawasly and Fahim Dalvi and Nadir Durrani},
  title = {{Scaled-up Discovery of Latent Concepts in Deep NLP Models}},
  booktitle = {EACL},
  year = {2024},
  url = {https://openreview.net/forum?id=mQ4sbcqvWu},
}
Figure