Skip to content

๐ŸŽฏ Deep Learning Model Analysis Made Easy: Visualize and understand your model's behavior, attention patterns, and decision boundaries with interactive visualizations.

License

Notifications You must be signed in to change notification settings

Parisaroozgarian/model-interpretability

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

9 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿค– Model Interpretability Framework

A deep learning model visualization and interpretation framework that helps understand model behavior through interactive visualizations.

Stars PyPI Version Python License Tests Code style

๐ŸŒŸ Overview

This framework provides tools to analyze and visualize:

  • ๐Ÿงฎ Model attention patterns
  • ๐Ÿ“Š Token importance scores
  • ๐ŸŽฏ Uncertainty landscapes
  • ๐Ÿ”ฎ Embedding spaces
  • โšก Layer dynamics
  • ๐ŸŽฒ Decision boundaries

โœจ Key Features

๐Ÿ“Š 1. Basic Visualizations

  • ๐Ÿ“ˆ Token importance bar charts
  • ๐Ÿ”ฅ Attention heatmaps
  • ๐Ÿ“‰ Confidence scores

๐Ÿ”ฌ 2. Advanced Analysis

  • ๐ŸŒŒ 2D embedding space visualization
  • ๐Ÿ”„ Cross-model comparisons
  • ๐Ÿ“ฑ Interactive plots with Plotly

๐Ÿš€ 3. Deep Model Analysis

  • ๐Ÿ”„ Layer-wise representation dynamics
  • ๐Ÿ“Š Multi-metric visualization
  • โšก Attention flow patterns

๐ŸŽฏ 4. Uncertainty Analysis

  • ๐ŸŒ 3D uncertainty landscapes
  • ๐Ÿ“ˆ Predictive entropy visualization
  • ๐Ÿ“‰ Confidence evolution plots

๐Ÿš€ Quick Start

  1. 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 .
  1. 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()

๐Ÿ“š Examples

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

๐Ÿ“ Project Structure

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

๐Ÿ› ๏ธ Dependencies

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

๐Ÿ‘จโ€๐Ÿ’ป Development

Run tests:

python -m pytest tests/

Code coverage:

pytest tests/ --cov=src/ --cov-report=xml

๐Ÿ‘ฉโ€๐Ÿ’ป Author

Parisa Roozgarian

๐Ÿ™ Acknowledgments

  • ๐Ÿค— BERT model from Hugging Face Transformers
  • ๐Ÿ“Š Plotly for interactive visualizations
  • ๐ŸŒ UMAP for dimensionality reduction

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details

About

๐ŸŽฏ Deep Learning Model Analysis Made Easy: Visualize and understand your model's behavior, attention patterns, and decision boundaries with interactive visualizations.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages