A deep learning model visualization and interpretation framework that helps understand model behavior through interactive visualizations.
This framework provides tools to analyze and visualize:
- ๐งฎ Model attention patterns
- ๐ Token importance scores
- ๐ฏ Uncertainty landscapes
- ๐ฎ Embedding spaces
- โก Layer dynamics
- ๐ฒ Decision boundaries
- ๐ Token importance bar charts
- ๐ฅ Attention heatmaps
- ๐ Confidence scores
- ๐ 2D embedding space visualization
- ๐ Cross-model comparisons
- ๐ฑ Interactive plots with Plotly
- ๐ Layer-wise representation dynamics
- ๐ Multi-metric visualization
- โก Attention flow patterns
- ๐ 3D uncertainty landscapes
- ๐ Predictive entropy visualization
- ๐ Confidence evolution plots
- Install the package:
git clone https://github.com/Parisaroozgarian/model-interpretability.git
cd model-interpretability
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
pip install -e .
- Basic usage:
from src.config.visualization_config import VisualizationConfig
from src.visualizers.feature_importance import FeatureImportanceVisualizer
# Initialize
config = VisualizationConfig()
viz = FeatureImportanceVisualizer(config)
# Create visualization
fig = viz.plot_token_importance(
tokens=["This", "is", "a", "test"],
importance_scores=[0.3, 0.2, 0.1, 0.4]
)
fig.show()
Check the examples/
directory for more usage examples:
- ๐
basic_visualization.py
: Simple token importance and uncertainty plots - ๐ฌ
advanced_visualization.py
: 2D embedding space and attention patterns - ๐
deep_analysis.py
: Layer dynamics and model behavior analysis
model-interpretability/
โโโ src/ # Source code
โ โโโ config/ # โ๏ธ Configuration settings
โ โ โโโ visualization_config.py
โ โโโ visualizers/ # ๐ Visualization modules
โ โ โโโ base.py
โ โ โโโ feature_importance.py
โ โ โโโ uncertainty.py
โ โ โโโ advanced.py
โ โ โโโ deep_analysis.py
โ โโโ utils/ # ๐ ๏ธ Utility functions
โโโ examples/ # ๐ Usage examples
โโโ tests/ # ๐งช Test suite
โโโ docs/ # ๐ Documentation
torch>=1.9.0
transformers>=4.5.0
plotly>=5.1.0
numpy>=1.19.5
seaborn>=0.11.2
tensorflow-hub>=0.12.0
nltk>=3.6.3
umap-learn>=0.5.1
scikit-learn>=0.24.2
networkx>=2.6.2
Run tests:
python -m pytest tests/
Code coverage:
pytest tests/ --cov=src/ --cov-report=xml
- ๐ค BERT model from Hugging Face Transformers
- ๐ Plotly for interactive visualizations
- ๐ UMAP for dimensionality reduction
This project is licensed under the MIT License - see the LICENSE file for details