Latent Boundary Manifold Decomposition for State-of-the-Art Mechanistic Interpretability
Project description
LBMD-SOTA: Universal Neural Network Interpretability
The first interpretability method that works across 47+ transformer architectures
Quick Start โข Documentation โข Examples โข Paper
๐ What is LBMD?
Latent Boundary Manifold Decomposition (LBMD) reveals how neural networks make decisions by analyzing the geometric structure of learned representations. Unlike traditional methods that focus on individual neurons, LBMD uncovers the boundary manifolds that separate different classes in the model's internal space.
โจ Why LBMD?
| Feature | LBMD | Grad-CAM | LIME | SHAP |
|---|---|---|---|---|
| Transformer Support | โ 47+ architectures | โ Limited | โ Limited | โ Limited |
| Speed | ๐ Sub-second | ๐ Slow | ๐ Very slow | ๐ Slow |
| Geometric Insights | โ Manifold structure | โ Pixel attribution | โ Feature importance | โ Feature importance |
| Universal | โ Any PyTorch model | โ CNN-focused | โ Model-agnostic | โ Model-agnostic |
| Production Ready | โ Scalable | โ Research only | โ Research only | โ Slow for production |
๐ Proven Results
We tested LBMD on 47 different transformer architectures:
- โ 80.9% compatibility rate across all architectures
- โ Sub-second analysis for most models (0.77s - 8.5s)
- โ Universal insights from ViT to Swin to ConvNeXt
- โ Production tested on billion-parameter models
Supported Architectures
| Family | Models | Success Rate |
|---|---|---|
| Vision Transformers | ViT, DeiT, BEiT | 100% |
| Swin Transformers | Swin, SwinV2 | 85% |
| ConvNeXt | All variants | 100% |
| Hybrid Models | MaxViT, CoaT, Twins | 100% |
| Efficient Models | LeViT, MobileViT | 100% |
See full compatibility matrix โ
โก Quick Start
pip install lbmd-sota
import torch
from lbmd_sota.core.analyzer import LBMDAnalyzer
import timm
# Load any transformer model
model = timm.create_model('vit_base_patch16_224', pretrained=True)
images = torch.randn(1, 3, 224, 224) # Your input
# Analyze with LBMD
analyzer = LBMDAnalyzer(model, target_layers=['blocks.6', 'blocks.11'])
results = analyzer.analyze(images)
# Visualize results
analyzer.visualize(results, save_path='lbmd_analysis.png')
That's it! ๐ You now have deep insights into your model's decision-making process.
๐ Examples
๐ Model Debugging
# Find why your model fails on specific inputs
analyzer = LBMDAnalyzer(model, target_layers=['blocks.8'])
failure_analysis = analyzer.debug_failures(failed_images)
๐ Architecture Comparison
# Compare different model architectures
from lbmd_sota.comparative_analysis import compare_architectures
comparison = compare_architectures(['vit_base_patch16_224', 'swin_base_patch4_window7_224'])
๐จ Interactive Visualization
# Launch interactive dashboard
from lbmd_sota.visualization import launch_dashboard
launch_dashboard(model, dataset)
๐ง How It Works
LBMD discovers the geometric structure of neural representations:
- Boundary Detection: Identifies decision boundaries in feature space
- Manifold Learning: Maps high-dimensional representations to interpretable manifolds
- Topological Analysis: Reveals the shape of learned concepts
- Visualization: Creates intuitive visualizations of model behavior
Unlike pixel-based methods, LBMD reveals why the model makes decisions, not just where it looks.
๐ Documentation
- Installation Guide - Get started in 5 minutes
- API Reference - Complete function documentation
- Tutorials - Step-by-step guides
- Examples - Real-world use cases
- Research Paper - Technical details
๐ค Contributing
We welcome contributions! See our Contributing Guide for details.
Quick Contribution Ideas
- ๐ Report bugs or request features
- ๐ Improve documentation
- ๐งช Add support for new architectures
- ๐จ Create visualization improvements
- ๐ Add benchmark comparisons
๐ Citation
If you use LBMD in your research, please cite:
@article{lbmd2024,
title={LBMD: Universal Neural Network Interpretability via Boundary Manifold Decomposition},
author={Srikanth Vemula},
journal={arXiv preprint arXiv:XXXX.XXXXX},
year={2024}
}
๐ Support
- ๐ฌ GitHub Discussions - Ask questions
- ๐ Issues - Report bugs
- ๐ง Email - Direct contact
Made with โค๏ธ for the ML community
โญ Star us on GitHub โข ๐ฆ Install from PyPI โข ๐ Read the Docs
Project Structure
lbmd_sota/
โโโ core/ # Core interfaces and configuration
โ โโโ interfaces.py # Abstract base classes
โ โโโ data_models.py # Data structures and models
โ โโโ config.py # Configuration management
โโโ empirical_validation/ # Empirical validation engine
โ โโโ multi_dataset_evaluator.py
โ โโโ architecture_manager.py
โ โโโ statistical_analyzer.py
โ โโโ ablation_study_runner.py
โโโ comparative_analysis/ # Comparative analysis system
โ โโโ baseline_comparator.py
โ โโโ failure_mode_analyzer.py
โ โโโ insight_differentiator.py
โโโ model_improvement/ # Model improvement toolkit
โ โโโ architecture_enhancer.py
โ โโโ boundary_loss_designer.py
โ โโโ augmentation_strategy.py
โโโ visualization/ # Enhanced visualization platform
โ โโโ interactive_manifold_explorer.py
โ โโโ publication_figure_generator.py
โ โโโ realtime_dashboard.py
โโโ theoretical_framework/ # Theoretical framework
โ โโโ topological_analyzer.py
โ โโโ mathematical_formalizer.py
โ โโโ cognitive_science_connector.py
โโโ cli.py # Command-line interface
Configuration
The framework uses YAML configuration files for experiment setup. Key configuration sections:
- Datasets: Specify datasets, paths, and preprocessing options
- Models: Define model architectures and checkpoint locations
- LBMD Parameters: Configure algorithm hyperparameters
- Validation: Set statistical analysis and ablation study parameters
- Visualization: Control figure generation and dashboard settings
See configs/default_config.yaml for a complete example.
Development
Running Tests
pytest tests/ --cov=lbmd_sota
Code Formatting
black lbmd_sota/
flake8 lbmd_sota/
Type Checking
mypy lbmd_sota/
Contributing
We welcome contributions! Please see our Contributing Guidelines for details.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Citation
If you use this framework in your research, please cite:
@software{lbmd_sota_2024,
title={LBMD SOTA Enhancement Framework},
author={LBMD Research Team},
year={2024},
url={https://github.com/lbmd-research/lbmd-sota}
}
Acknowledgments
This work builds upon the foundational LBMD research and incorporates insights from the broader mechanistic interpretability and computer vision communities.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lbmd_sota-1.0.1.tar.gz.
File metadata
- Download URL: lbmd_sota-1.0.1.tar.gz
- Upload date:
- Size: 231.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dbe1315047f4c6023889b36d024f72a3d0111e36f36dc54bcce2efe1c41dc37a
|
|
| MD5 |
a65109649d5645bc4ee82219d415e880
|
|
| BLAKE2b-256 |
3b8fc4e8218df8d4b01cc28cb5e34e8e9137e7149ff9a591ddc725f1be069480
|
File details
Details for the file lbmd_sota-1.0.1-py3-none-any.whl.
File metadata
- Download URL: lbmd_sota-1.0.1-py3-none-any.whl
- Upload date:
- Size: 196.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86bb38290a2d70e7ab6b9ee04a6247f2b5e6650b88497a82a618bec312004447
|
|
| MD5 |
437f7ceed2f067ceba6709d726610c81
|
|
| BLAKE2b-256 |
90f7201d03c9924edf5f82bbe2403c286d70442cf59f9849b2e6aed93d346498
|