A PyTorch library implementing class activation map (CAM) methods to visualize which image regions drive a computer vision model's predictions.
pyc-team/pytorch_concepts
A PyTorch Lightning-based library for building concept-based, interpretable deep learning models with annotated tensors, interventions and probabilistic graphical models.
- Stars
- 293
- Forks
- 30
- Open issues
- 11
- Last commit
- 3 days ago
What is it?
PyC (PyTorch Concepts) is a Python library built on PyTorch and PyTorch Lightning for designing deep learning models whose predictions are expressed through human-understandable concepts. Instead of mapping inputs straight to targets, models are structured so that concepts are named, computed, trained and can be inspected or edited.
The library provides annotated tensors that bind values to concept names, types and cardinalities, concept layers and losses that score each concept by its type, and an intervention context manager that overrides selected concept values during a forward pass. Mid-level APIs let users define interpretable probabilistic graphical models over concepts and embeddings and run inference on them.
PyC is organized in layers: low-level interpretable layers, mid-level probabilistic models, high-level ready-made models usable as PyTorch or Lightning modules, and a configuration-driven no-code tool called Conceptarium built on Hydra and WandB for running large-scale experiments. The project is marked as alpha, so public APIs may change between releases.
Key features
- 01Annotated tensors that slice data by concept name or concept type.
- 02Concept layers that map embeddings or concepts to concepts.
- 03Concept losses that apply the appropriate loss for binary, categorical and continuous concepts.
- 04Intervention context manager to set concept values during a forward pass.
- 05Probabilistic graphical model APIs for conditional distributions over concepts.
- 06Configuration-driven experiments via Conceptarium, built on Hydra and WandB.
Use cases
- Building image or tabular classifiers whose intermediate predictions are human-readable concepts.
- Testing how a model's output changes when specific concepts are overridden by intervention.
- Researching concept-based models and benchmarking them across datasets with configuration files.
- Modeling conditional dependencies between concepts and targets with probabilistic graphical models.
Quick start
- 1
Install the library from PyPI with data extras
pip install --pre "pytorch-concepts[data]" - 2
Or install the core-only version without data dependencies
pip install --pre pytorch-concepts
Things to know
- Alpha software: public APIs may change and be unstable between releases.
- Installation requires the --pre flag, indicating pre-release builds.
Topics
FAQ
- What is pytorch_concepts?
- A PyTorch Lightning-based library for building concept-based, interpretable deep learning models with annotated tensors, interventions and probabilistic graphical models. PyC (PyTorch Concepts) is a Python library built on PyTorch and PyTorch Lightning for designing deep learning models whose predictions are expressed through human-understandable concepts. Instead of mapping inputs straight to targets, models are structured so that concepts are named, computed, trained and can be inspected or edited.
- Is pytorch_concepts free to use? What license does it have?
- pytorch_concepts is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
- Is pytorch_concepts still maintained?
- Actively maintained. The last commit to pytorch_concepts was on Nov 4, 2026.
- What can I use pytorch_concepts for?
- Building image or tabular classifiers whose intermediate predictions are human-readable concepts. Testing how a model's output changes when specific concepts are overridden by intervention. Researching concept-based models and benchmarking them across datasets with configuration files. Modeling conditional dependencies between concepts and targets with probabilistic graphical models.
- How do I install pytorch_concepts?
- Install the library from PyPI with data extras: pip install --pre "pytorch-concepts[data]" Or install the core-only version without data dependencies: pip install --pre pytorch-concepts
- Where can I get pytorch_concepts?
- The source code and installation instructions are on GitHub: https://github.com/pyc-team/pytorch_concepts
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A model interpretability library for PyTorch that explains which input features, neurons and training examples drive a model's predictions.
An open-source Python toolkit for quantitatively evaluating neural network explanations with 30+ XAI metrics across PyTorch and TensorFlow.
A Python library for sliced inference that runs object detection models over tiles of large images to find small objects.
A suite of Python and web UI tools for assessing and debugging ML models for error patterns, fairness, interpretability and causal effects.
A JVM machine learning and AI platform covering classical ML, deep learning, NLP, visualization, and LLM/ONNX inference for Java, Kotlin and Scala.