Exploring Semantic Clustering in Deep Reinforcement Learning for Video Games

Liang Zhang, Justin Lieffers, Adarsh Pyarelal · DOI

Introduction

Deep Reinforcement Learning (DRL) has demonstrated exceptional performance in complex environments, yet the internal logic of these agents often remains a "black box." While an agent may achieve high scores, understanding why specific actions are taken in particular states is crucial for safety, debugging, and trust. Traditional visualization methods like t-SNE are frequently used to project high-dimensional features into 2D space, but they suffer from significant instability; minor changes in data or random seeds can lead to wildly different layouts. Furthermore, in static environments like Atari, it is often unclear if clustering is driven by semantic meaning or merely pixel-level similarities.

To address these challenges, researchers have introduced the Semantic Clustering Module (SCM). This framework automatically groups game states into human-interpretable categories by integrating dimensionality reduction and online clustering directly into the DRL training pipeline.

The Semantic Clustering Module (SCM)

The SCM architecture operates alongside standard DRL algorithms (such as PPO) to organize the agent's internal knowledge. It consists of two primary components:

  1. Feature Dimensionality Reduction (FDR) Net: Unlike post-hoc visualization techniques, the FDR net is trained online. It maps high-dimensional state features into a stable 2D space using a loss function based on the Student’s t-distribution, ensuring that relative distances between features are preserved throughout training.
  2. Online Clustering via Vector Quantization: Utilizing a mechanism similar to VQ-VAEs, the module employs a vector quantizer to assign states to discrete "VQ codes" or clusters. This process functions as an online version of k-means, segmenting the feature space into distinct, manageable regions.
Overview of the SCM architecture integrated into a classic DRL pipeline.

By feeding cluster information back into the policy network, the SCM encourages the agent to develop more organized internal representations without compromising task performance.

Experimental Framework

The SCM was evaluated using the Procgen benchmark, featuring games such as CoinRun, Ninja, Jumper, and FruitBot. Procgen environments are procedurally generated, meaning layouts and visual assets change with every episode. This setup ensures that any observed clustering reflects generalized semantic concepts—such as "approaching a hazard"—rather than the memorization of specific pixel patterns.

Stability and Semantic Organization

A core finding of this research is that semantic clustering is an intrinsic property of DRL agents. "Stop-gradient" experiments revealed that agents naturally group similar semantic states even without explicit clustering; the SCM simply sharpens and stabilizes these latent structures.

The FDR space offers a significant advantage over traditional t-SNE in terms of stability. While t-SNE results are often scattered and sensitive to hyperparameters, the FDR net produces consistent, well-separated maps of the agent's knowledge across different runs and data scales.

Comparison of t-SNE and FDR spaces across different conditions, highlighting the stability of the FDR method.

By examining the "mean images" of these clusters, researchers identified that each group corresponds to a specific high-level behavior or "skill," such as "preparing for a jump" or "navigating toward a goal."

Results and Interpretability

Human evaluations confirmed the semantic relevance of the clusters, with participants giving high scores (averaging >4.2/5.0) for the alignment between video clips within a cluster and their associated skill descriptions. Crucially, the SCM provides this interpretability with minimal impact on the agent's overall score, effectively offering "interpretability for free."

Furthermore, the module serves as a powerful tool for policy analysis. In Jumper, for instance, the SCM helped identify a logic error where the agent incorrectly identified a "goal" state based on radar data even when the physical goal was absent.

Conclusion

The Semantic Clustering Module represents a significant step toward transparent DRL. While currently limited by the need to pre-define the number of clusters ($K$), it provides a stable and automated way to decode an agent's internal "vocabulary" of skills. Future iterations may leverage Large Language Models (LLMs) to automatically generate natural language descriptions for these clusters, further closing the gap between machine logic and human understanding.

Summary updated

BibTeX
@inproceedings{zhang2025exploring,
  author = {Liang Zhang and Justin Lieffers and Adarsh Pyarelal},
  title = {{Exploring Semantic Clustering in Deep Reinforcement Learning for Video Games}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=YTk1kATzOd},
}
Figure