Downloads ยท 30 days
0
leonepson/semantic_rl
semantic_rl is a reinforcement learning model from leonepson. Use it for the reinforcement learning task on the model card, and read the license before you ship it in a product.
Authors: Liang Zhang, Justin Lieffers, Adarsh Pyarelal Conference: NeurIPS 2025 Main Track Paper: arXiv:2409.17411
Downloads ยท 30 days
0
Access
Public
Updated Nov 7, 2025
Repo size
48.9 MB
Likes
1
Public
Click a slice to open those files.
Other47.5 MB ยท 53%
From the Hugging Face model README
Authors: Liang Zhang, Justin Lieffers, Adarsh Pyarelal
Conference: NeurIPS 2025 Main Track
Paper: arXiv:2409.17411
This repository contains the official implementation of our research on enhancing interpretability in deep reinforcement learning through semantic clustering techniques. Our work extends the OpenAI train-procgen framework to incorporate semantic clustering methods for improved understanding and visualization of learned policies in procedural environments.
This work presents a novel approach to enhancing interpretability in deep reinforcement learning by leveraging semantic clustering techniques. We demonstrate how semantic clustering can provide insights into learned policies, enabling better understanding of agent behavior and decision-making processes in complex procedural environments.
Prerequisite: Python 3.8.
Clone the repository:
git clone https://github.com/ualiangzhang/semantic_rl.git
cd semantic_rl
Install dependencies (Python 3.8):
pip install -r requirements.txt
Install Procgen environments: Follow the installation steps in the Procgen repository.
Train a semantic clustering model:
python -m train_procgen.train_sppo --env_name <ENV_NAME> --num_levels 0 --distribution_mode easy --timesteps_per_proc 25000000 --rand_seed <RAND_SEED>
Train a baseline model:
python -m train_procgen.train_ppo --env_name <ENV_NAME> --num_levels 0 --distribution_mode easy --timesteps_per_proc 25000000 --rand_seed <RAND_SEED>
Generate generalization figures for a single game:
cd train_procgen
python single_graph.py --env_name <ENV_NAME>
# Example:
python single_graph.py --env_name coinrun
Generate embedding space visualizations:
python -m train_procgen.enjoy_sppo --env_name <ENV_NAME> --mode 1
Generate skill demonstration videos:
python -m train_procgen.enjoy_sppo --env_name <ENV_NAME> --mode 0
Interactive cluster exploration:
python -m train_procgen.hover_clusters --env_name <ENV_NAME>
# Example:
python -m train_procgen.hover_clusters --env_name fruitbot
Our implementation supports four Procgen environments:
The following videos demonstrate the 8 distinct semantic clusters learned by our model in the Ninja environment. Each cluster represents a different behavioral pattern and skill set:
| Cluster | Behavior |
|---|---|
| 0 | The agent starts by walking through the first platform and then performs a high jump to reach a higher ledge. |
| 1 | The agent makes small jumps in the middle of the scene. |
| 2 | Two interpretations are present: (1) the agent starts from the leftmost end of the scene and walks to the starting position of Cluster 0; (2) when there are no higher ledges to jump to, the agent begins from the scene, walks over the first platform, and prepares to jump to the subsequent ledge. |
| 3 | The agent walks on the ledge and prepares to jump to a higher ledge. |
| 4 | After performing a high jump, the agent loses sight of the ledge below. |
| 5 | The agent walks on the ledge and prepares to jump onto a ledge at the same height or lower. |
| 6 | The agent executes a high jump while keeping the ledge below in sight. |
| 7 | The agent moves towards the right edge of the scene and touches the mushroom. |
You can also generate these videos yourself using our code:
# Generate Ninja skill cluster videos
python -m train_procgen.enjoy_sppo --env_name ninja --mode 0 --num_embeddings 8
Note: These videos showcase the distinct behavioral patterns learned by our semantic clustering approach. Each cluster demonstrates different combat strategies, movement patterns, and decision-making processes in the Ninja environment.
baseline/ # Required RL training package
train_procgen/
โโโ checkpoints/ # Trained model checkpoints
โโโ figures/ # Generated visualizations and videos
videos/ # video clips corresponding to the clusters in the paper
To reproduce the results from our paper:
train_procgen/checkpoints/. You can skip training and directly run the visualization scripts. Otherwise, train models using the commands above.Note: Video generation may take 30-60 minutes depending on machine performance, as it ensures comprehensive exploration of all clusters.
<!-- ## ๐ค Citation If you use this code in your research, please cite our paper: --> <!-- ```bibtex @article{zhang2025enhancing, title={Enhancing Interpretability in Deep Reinforcement Learning through Semantic Clustering}, author={Zhang, Liang and Lieffers, Justin and Pyarelal, Adarsh}, journal={Advances in Neural Information Processing Systems}, year={2025} } ``` -->This project is licensed under the MIT License - see the LICENSE file for details.
This work builds upon the OpenAI train-procgen framework. We thank the original authors for their excellent work on procedural generation for reinforcement learning benchmarking.