interpreto 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. interpreto-0.2.2/.editorconfig +24 -0
  2. interpreto-0.2.2/.gitignore +179 -0
  3. interpreto-0.2.2/.pre-commit-config.yaml +74 -0
  4. interpreto-0.2.2/CHANGELOG.md +3 -0
  5. interpreto-0.2.2/CODE_OF_CONDUCT.md +76 -0
  6. interpreto-0.2.2/LICENSE +23 -0
  7. interpreto-0.2.2/MANIFEST.in +13 -0
  8. interpreto-0.2.2/PKG-INFO +283 -0
  9. interpreto-0.2.2/README.md +186 -0
  10. interpreto-0.2.2/SECURITY.md +30 -0
  11. interpreto-0.2.2/attribution_walkthrough.ipynb +7237 -0
  12. interpreto-0.2.2/concept_examples.ipynb +200 -0
  13. interpreto-0.2.2/interpreto/__init__.py +55 -0
  14. interpreto-0.2.2/interpreto/attributions/__init__.py +20 -0
  15. interpreto-0.2.2/interpreto/attributions/aggregations/__init__.py +1 -0
  16. interpreto-0.2.2/interpreto/attributions/aggregations/base.py +140 -0
  17. interpreto-0.2.2/interpreto/attributions/aggregations/linear_regression_aggregation.py +194 -0
  18. interpreto-0.2.2/interpreto/attributions/aggregations/sobol_aggregation.py +116 -0
  19. interpreto-0.2.2/interpreto/attributions/base.py +668 -0
  20. interpreto-0.2.2/interpreto/attributions/methods/__init__.py +17 -0
  21. interpreto-0.2.2/interpreto/attributions/methods/integrated_gradients.py +86 -0
  22. interpreto-0.2.2/interpreto/attributions/methods/kernel_shap.py +106 -0
  23. interpreto-0.2.2/interpreto/attributions/methods/lime.py +114 -0
  24. interpreto-0.2.2/interpreto/attributions/methods/occlusion.py +90 -0
  25. interpreto-0.2.2/interpreto/attributions/methods/saliency.py +78 -0
  26. interpreto-0.2.2/interpreto/attributions/methods/smooth_grad.py +87 -0
  27. interpreto-0.2.2/interpreto/attributions/methods/sobol_attribution.py +109 -0
  28. interpreto-0.2.2/interpreto/attributions/metrics/__init__.py +0 -0
  29. interpreto-0.2.2/interpreto/attributions/metrics/base.py +0 -0
  30. interpreto-0.2.2/interpreto/attributions/perturbations/__init__.py +31 -0
  31. interpreto-0.2.2/interpreto/attributions/perturbations/base.py +415 -0
  32. interpreto-0.2.2/interpreto/attributions/perturbations/gaussian_noise_perturbation.py +83 -0
  33. interpreto-0.2.2/interpreto/attributions/perturbations/linear_interpolation_perturbation.py +113 -0
  34. interpreto-0.2.2/interpreto/attributions/perturbations/occlusion_perturbation.py +80 -0
  35. interpreto-0.2.2/interpreto/attributions/perturbations/random_perturbation.py +90 -0
  36. interpreto-0.2.2/interpreto/attributions/perturbations/shap_perturbation.py +113 -0
  37. interpreto-0.2.2/interpreto/attributions/perturbations/sobol_perturbation.py +135 -0
  38. interpreto-0.2.2/interpreto/attributions/plots/__init__.py +0 -0
  39. interpreto-0.2.2/interpreto/commons/__init__.py +28 -0
  40. interpreto-0.2.2/interpreto/commons/distances.py +271 -0
  41. interpreto-0.2.2/interpreto/commons/generator_tools.py +168 -0
  42. interpreto-0.2.2/interpreto/commons/granularity.py +214 -0
  43. interpreto-0.2.2/interpreto/concepts/__init__.py +64 -0
  44. interpreto-0.2.2/interpreto/concepts/base.py +389 -0
  45. interpreto-0.2.2/interpreto/concepts/interpretations/__init__.py +27 -0
  46. interpreto-0.2.2/interpreto/concepts/interpretations/base.py +104 -0
  47. interpreto-0.2.2/interpreto/concepts/interpretations/topk_inputs.py +354 -0
  48. interpreto-0.2.2/interpreto/concepts/methods/__init__.py +69 -0
  49. interpreto-0.2.2/interpreto/concepts/methods/cockatiel.py +91 -0
  50. interpreto-0.2.2/interpreto/concepts/methods/neurons_as_concepts.py +140 -0
  51. interpreto-0.2.2/interpreto/concepts/methods/overcomplete.py +691 -0
  52. interpreto-0.2.2/interpreto/concepts/metrics/__init__.py +43 -0
  53. interpreto-0.2.2/interpreto/concepts/metrics/consim.py +77 -0
  54. interpreto-0.2.2/interpreto/concepts/metrics/dictionary_metrics.py +198 -0
  55. interpreto-0.2.2/interpreto/concepts/metrics/reconstruction_metrics.py +166 -0
  56. interpreto-0.2.2/interpreto/concepts/metrics/sparsity_metrics.py +97 -0
  57. interpreto-0.2.2/interpreto/concepts/plots/__init__.py +0 -0
  58. interpreto-0.2.2/interpreto/model_wrapping/__init__.py +27 -0
  59. interpreto-0.2.2/interpreto/model_wrapping/classification_inference_wrapper.py +227 -0
  60. interpreto-0.2.2/interpreto/model_wrapping/generation_inference_wrapper.py +215 -0
  61. interpreto-0.2.2/interpreto/model_wrapping/inference_wrapper.py +656 -0
  62. interpreto-0.2.2/interpreto/model_wrapping/llm_interface.py +130 -0
  63. interpreto-0.2.2/interpreto/model_wrapping/model_with_split_points.py +356 -0
  64. interpreto-0.2.2/interpreto/model_wrapping/splitting_utils.py +125 -0
  65. interpreto-0.2.2/interpreto/model_wrapping/transformers_classes.py +88 -0
  66. interpreto-0.2.2/interpreto/typing.py +94 -0
  67. interpreto-0.2.2/interpreto/visualizations/__init__.py +0 -0
  68. interpreto-0.2.2/interpreto/visualizations/attributions/__init__.py +0 -0
  69. interpreto-0.2.2/interpreto/visualizations/attributions/classification_highlight.py +389 -0
  70. interpreto-0.2.2/interpreto/visualizations/base.py +226 -0
  71. interpreto-0.2.2/interpreto/visualizations/colormap_helpers.py +59 -0
  72. interpreto-0.2.2/interpreto/visualizations/concepts/__init__.py +0 -0
  73. interpreto-0.2.2/interpreto/visualizations/concepts/concepts_highlight.py +176 -0
  74. interpreto-0.2.2/interpreto/visualizations/visualization.css +129 -0
  75. interpreto-0.2.2/interpreto/visualizations/visualization.js +606 -0
  76. interpreto-0.2.2/interpreto/visualizations/visualization_attribution.js +593 -0
  77. interpreto-0.2.2/interpreto.egg-info/PKG-INFO +283 -0
  78. interpreto-0.2.2/interpreto.egg-info/SOURCES.txt +84 -0
  79. interpreto-0.2.2/interpreto.egg-info/dependency_links.txt +1 -0
  80. interpreto-0.2.2/interpreto.egg-info/requires.txt +45 -0
  81. interpreto-0.2.2/interpreto.egg-info/top_level.txt +1 -0
  82. interpreto-0.2.2/mkdocs.yml +176 -0
  83. interpreto-0.2.2/pyproject.toml +240 -0
  84. interpreto-0.2.2/requirements-dev.txt +549 -0
  85. interpreto-0.2.2/requirements.txt +298 -0
  86. interpreto-0.2.2/setup.cfg +4 -0
@@ -0,0 +1,24 @@
1
+ # Check http://editorconfig.org for more information
2
+ # This is the main config file for this project:
3
+ root = true
4
+
5
+ [*]
6
+ charset = utf-8
7
+ end_of_line = lf
8
+ insert_final_newline = true
9
+ indent_style = space
10
+ indent_size = 2
11
+ trim_trailing_whitespace = true
12
+
13
+ [*.{py, pyi}]
14
+ indent_style = space
15
+ indent_size = 4
16
+
17
+ [Makefile]
18
+ indent_style = tab
19
+
20
+ [*.md]
21
+ trim_trailing_whitespace = false
22
+
23
+ [*.{diff,patch}]
24
+ trim_trailing_whitespace = false
@@ -0,0 +1,179 @@
1
+ .DS_Store
2
+
3
+ # Byte-compiled / optimized / DLL files
4
+ __pycache__/
5
+ *.py[cod]
6
+ *$py.class
7
+
8
+ # C extensions
9
+ *.so
10
+
11
+ # Distribution / packaging
12
+ .Python
13
+ build/
14
+ develop-eggs/
15
+ dist/
16
+ downloads/
17
+ eggs/
18
+ .eggs/
19
+ lib/
20
+ lib64/
21
+ parts/
22
+ sdist/
23
+ var/
24
+ wheels/
25
+ share/python-wheels/
26
+ *.egg-info/
27
+ .installed.cfg
28
+ *.egg
29
+ MANIFEST
30
+
31
+ # PyInstaller
32
+ # Usually these files are written by a python script from a template
33
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
34
+ *.manifest
35
+ *.spec
36
+
37
+ # Installer logs
38
+ pip-log.txt
39
+ pip-delete-this-directory.txt
40
+
41
+ # Unit test / coverage reports
42
+ htmlcov/
43
+ .tox/
44
+ .nox/
45
+ .coverage
46
+ .coverage.*
47
+ .cache
48
+ nosetests.xml
49
+ coverage.xml
50
+ *.cover
51
+ *.py,cover
52
+ .hypothesis/
53
+ .pytest_cache/
54
+ cover/
55
+
56
+ # Translations
57
+ *.mo
58
+ *.pot
59
+
60
+ # Django stuff:
61
+ *.log
62
+ local_settings.py
63
+ db.sqlite3
64
+ db.sqlite3-journal
65
+
66
+ # Flask stuff:
67
+ instance/
68
+ .webassets-cache
69
+
70
+ # Scrapy stuff:
71
+ .scrapy
72
+
73
+ # Sphinx documentation
74
+ docs/_build/
75
+
76
+ # PyBuilder
77
+ .pybuilder/
78
+ target/
79
+
80
+ # Jupyter Notebook
81
+ .ipynb_checkpoints
82
+
83
+ # IPython
84
+ profile_default/
85
+ ipython_config.py
86
+
87
+ # pyenv
88
+ # For a library or package, you might want to ignore these files since the code is
89
+ # intended to run in multiple environments; otherwise, check them in:
90
+ # .python-version
91
+
92
+ # pipenv
93
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
94
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
95
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
96
+ # install all needed dependencies.
97
+ #Pipfile.lock
98
+
99
+ # UV
100
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
101
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
102
+ # commonly ignored for libraries.
103
+ #uv.lock
104
+
105
+ # poetry
106
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
107
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
108
+ # commonly ignored for libraries.
109
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
110
+ #poetry.lock
111
+
112
+ # pdm
113
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
114
+ #pdm.lock
115
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
116
+ # in version control.
117
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
118
+ .pdm.toml
119
+ .pdm-python
120
+ .pdm-build/
121
+
122
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
123
+ __pypackages__/
124
+
125
+ # Celery stuff
126
+ celerybeat-schedule
127
+ celerybeat.pid
128
+
129
+ # SageMath parsed files
130
+ *.sage.py
131
+
132
+ # Environments
133
+ .env
134
+ .venv
135
+ env/
136
+ venv/
137
+ ENV/
138
+ env.bak/
139
+ venv.bak/
140
+
141
+ # Spyder project settings
142
+ .spyderproject
143
+ .spyproject
144
+
145
+ # Rope project settings
146
+ .ropeproject
147
+
148
+ # mkdocs documentation
149
+ /site
150
+
151
+ # mypy
152
+ .mypy_cache/
153
+ .dmypy.json
154
+ dmypy.json
155
+
156
+ # Pyre type checker
157
+ .pyre/
158
+
159
+ # pytype static type analyzer
160
+ .pytype/
161
+
162
+ # Cython debug symbols
163
+ cython_debug/
164
+
165
+ # PyCharm
166
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
167
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
168
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
169
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
170
+ #.idea/
171
+
172
+ # PyPI configuration file
173
+ .pypirc
174
+
175
+ # VSCode
176
+ .vscode/
177
+
178
+ # Codex
179
+ codex.patch
@@ -0,0 +1,74 @@
1
+ default_language_version:
2
+ python: python3
3
+
4
+ default_stages: [pre-commit, pre-push]
5
+
6
+ repos:
7
+ - repo: https://github.com/pre-commit/pre-commit-hooks
8
+ rev: v5.0.0
9
+ hooks:
10
+ - id: trailing-whitespace
11
+ - id: check-ast
12
+ - id: check-yaml
13
+ exclude: mkdocs.yml # Non-standard syntax for pymdownx not supported
14
+ - id: check-added-large-files
15
+ args: ['--maxkb=2500']
16
+ - id: check-docstring-first
17
+ - id: check-toml
18
+ - id: check-merge-conflict
19
+ - id: mixed-line-ending
20
+ args: ['--fix=lf']
21
+ - id: end-of-file-fixer
22
+ exclude: LICENSE
23
+
24
+ - repo: https://github.com/astral-sh/ruff-pre-commit
25
+ rev: v0.11.0
26
+ hooks:
27
+ - id: ruff-format
28
+ - id: ruff
29
+
30
+ - repo: local
31
+ hooks:
32
+ - id: fast-test
33
+ name: fast-test
34
+ entry: make
35
+ args: ["fast-test"]
36
+ language: system
37
+ pass_filenames: false
38
+ - id: clean
39
+ name: clean
40
+ entry: make
41
+ args: ["clean"]
42
+ language: system
43
+ pass_filenames: false
44
+
45
+ - repo: https://github.com/Lucas-C/pre-commit-hooks
46
+ rev: v1.5.5
47
+ hooks:
48
+ - id: insert-license
49
+ name: Add MIT license to docs
50
+ exclude: ^(docs/source)
51
+ files: \.py$
52
+ args:
53
+ - --license-filepath
54
+ - LICENSE
55
+
56
+ - repo: https://github.com/Lucas-C/pre-commit-hooks
57
+ rev: v1.5.5
58
+ hooks:
59
+ - id: insert-license
60
+ name: insert MIT license
61
+ exclude: ^(docs/source)
62
+ files: \.py$
63
+ args:
64
+ - --license-filepath
65
+ - LICENSE
66
+
67
+ - repo: local
68
+ hooks:
69
+ - id: docs
70
+ name: build docs
71
+ entry: make
72
+ args: ["build-docs"]
73
+ language: system
74
+ pass_filenames: false
@@ -0,0 +1,3 @@
1
+ # Changelog
2
+
3
+ *This file contains a high-level description of changes that were merged into the main branch since the last release. Refer to the releases page for an exhaustive overview of changes introduced at each release.*
@@ -0,0 +1,76 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, sex characteristics, gender identity and expression,
9
+ level of experience, education, socio-economic status, nationality, personal
10
+ appearance, race, religion, or sexual identity and orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at [fanny.jourdan@irt-saintexupery.com](mailto:fanny.jourdan@irt-saintexupery.com). All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at <https://www.contributor-covenant.org/version/1/4/code-of-conduct.html>
72
+
73
+ [homepage]: https://www.contributor-covenant.org
74
+
75
+ For answers to common questions about this code of conduct, see
76
+ <https://www.contributor-covenant.org/faq>
@@ -0,0 +1,23 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 IRT Antoine de Saint ExupΓ©ry et UniversitΓ© Paul Sabatier Toulouse III - All
4
+ rights reserved. DEEL and FOR are research programs operated by IVADO, IRT Saint ExupΓ©ry,
5
+ CRIAQ and ANITI - https://www.deel.ai/.
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
@@ -0,0 +1,13 @@
1
+ include LICENSE
2
+ include requirements.txt
3
+ include *.md
4
+ include *.py
5
+ include *.yaml
6
+ include *.yml
7
+ recursive-include interpreto *.py
8
+
9
+ exclude Makefile
10
+ prune .github
11
+ prune docs
12
+ prune examples
13
+ prune tests
@@ -0,0 +1,283 @@
1
+ Metadata-Version: 2.4
2
+ Name: interpreto
3
+ Version: 0.2.2
4
+ Summary: Interpretability toolbox for LLMs
5
+ Author: FOR Team
6
+ Author-email: fanny.jourdan@irt-saintexupery.com
7
+ Maintainer-email: Fanny Jourdan <fanny.jourdan@irt-saintexupery.com>, Antonin PochΓ© <antonin.poche@irt-saintexupery.com>, Thomas Mullor <thomas.mullor@irt-saintexupery.com>, Gabriele Sarti <gabriele.sarti996@gmail.com>
8
+ License: MIT License
9
+
10
+ Copyright (c) 2025 IRT Antoine de Saint ExupΓ©ry et UniversitΓ© Paul Sabatier Toulouse III - All
11
+ rights reserved. DEEL and FOR are research programs operated by IVADO, IRT Saint ExupΓ©ry,
12
+ CRIAQ and ANITI - https://www.deel.ai/.
13
+
14
+ Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ of this software and associated documentation files (the "Software"), to deal
16
+ in the Software without restriction, including without limitation the rights
17
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ copies of the Software, and to permit persons to whom the Software is
19
+ furnished to do so, subject to the following conditions:
20
+
21
+ The above copyright notice and this permission notice shall be included in all
22
+ copies or substantial portions of the Software.
23
+
24
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
+ SOFTWARE.
31
+
32
+ Project-URL: homepage, https://github.com/FOR-sight-ai/interpreto
33
+ Project-URL: documentation, https://github.com/FOR-sight-ai/interpreto
34
+ Project-URL: repository, https://github.com/FOR-sight-ai/interpreto
35
+ Project-URL: changelog, https://github.com/FOR-sight-ai/interpreto/blob/main/CHANGELOG.md
36
+ Classifier: Development Status :: 3 - Alpha
37
+ Classifier: Environment :: Console
38
+ Classifier: Environment :: GPU
39
+ Classifier: Environment :: GPU :: NVIDIA CUDA
40
+ Classifier: Framework :: Jupyter
41
+ Classifier: Intended Audience :: Developers
42
+ Classifier: Intended Audience :: Science/Research
43
+ Classifier: License :: OSI Approved :: Apache Software License
44
+ Classifier: Operating System :: OS Independent
45
+ Classifier: Programming Language :: Python
46
+ Classifier: Programming Language :: Python :: 3
47
+ Classifier: Programming Language :: Python :: 3.10
48
+ Classifier: Programming Language :: Python :: 3.11
49
+ Classifier: Programming Language :: Python :: 3.12
50
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
51
+ Classifier: Topic :: Scientific/Engineering :: Visualization
52
+ Classifier: Typing :: Typed
53
+ Requires-Python: >=3.10
54
+ Description-Content-Type: text/markdown
55
+ License-File: LICENSE
56
+ Requires-Dist: transformers[sentencepiece,tokenizers]>=4.22.0
57
+ Requires-Dist: torch>=2.0
58
+ Requires-Dist: overcomplete>=0.2.3
59
+ Requires-Dist: nnsight>=0.4.0
60
+ Requires-Dist: jaxtyping<=0.2.36
61
+ Requires-Dist: beartype
62
+ Requires-Dist: nvidia-cublas-cu11>=11.10.3.66; sys_platform == "Linux"
63
+ Requires-Dist: nvidia-cuda-cupti-cu11>=11.7.101; sys_platform == "Linux"
64
+ Requires-Dist: nvidia-cuda-nvrtc-cu11>=11.7.99; sys_platform == "Linux"
65
+ Requires-Dist: nvidia-cuda-runtime-cu11>=11.7.99; sys_platform == "Linux"
66
+ Requires-Dist: nvidia-cudnn-cu11>=8.5.0.96; sys_platform == "Linux"
67
+ Requires-Dist: nvidia-cufft-cu11>=10.9.0.58; sys_platform == "Linux"
68
+ Requires-Dist: nvidia-curand-cu11>=10.2.10.91; sys_platform == "Linux"
69
+ Requires-Dist: nvidia-cusolver-cu11>=11.4.0.1; sys_platform == "Linux"
70
+ Requires-Dist: nvidia-cusparse-cu11>=11.7.4.91; sys_platform == "Linux"
71
+ Requires-Dist: nvidia-nccl-cu11>=2.14.3; sys_platform == "Linux"
72
+ Requires-Dist: nvidia-nvtx-cu11>=11.7.91; sys_platform == "Linux"
73
+ Provides-Extra: docs
74
+ Requires-Dist: mkdocs>=1.6.1; extra == "docs"
75
+ Requires-Dist: mkdocs-material>=9.5.34; extra == "docs"
76
+ Requires-Dist: mkdocs-autorefs>=1.1.0; extra == "docs"
77
+ Requires-Dist: mkdocs-section-index>=0.3.9; extra == "docs"
78
+ Requires-Dist: mkdocstrings>=0.25.2; extra == "docs"
79
+ Requires-Dist: mkdocstrings-python>=1.10.9; extra == "docs"
80
+ Requires-Dist: mknotebooks>=0.8.0; extra == "docs"
81
+ Requires-Dist: docstr-coverage>=2.3.2; extra == "docs"
82
+ Provides-Extra: lint
83
+ Requires-Dist: setuptools; extra == "lint"
84
+ Requires-Dist: pydoclint>=0.4.0; extra == "lint"
85
+ Requires-Dist: pre-commit>=2.19.0; extra == "lint"
86
+ Requires-Dist: pytest>=7.2.0; extra == "lint"
87
+ Requires-Dist: pytest-cov>=4.0.0; extra == "lint"
88
+ Requires-Dist: pytest-xdist>=3.5.0; extra == "lint"
89
+ Requires-Dist: ruff>=0.2.0; extra == "lint"
90
+ Requires-Dist: virtualenv>=20.26.6; extra == "lint"
91
+ Requires-Dist: networkx>=3.0.0; extra == "lint"
92
+ Requires-Dist: numpy>=2.2.0; extra == "lint"
93
+ Provides-Extra: notebook
94
+ Requires-Dist: ipykernel>=6.29.2; extra == "notebook"
95
+ Requires-Dist: ipywidgets>=8.1.2; extra == "notebook"
96
+ Dynamic: license-file
97
+
98
+ <div align="center">
99
+ <img src="docs/assets/img/interpreto_banner.png" alt="Interpreto: Interpretability Toolkit for LLMs">
100
+ <br/>
101
+
102
+ [![Build status](https://img.shields.io/github/actions/workflow/status/FOR-sight-ai/interpreto/build.yml?branch=main)](https://github.com/FOR-sight-ai/interpreto/actions?query=workflow%3Abuild)
103
+ [![Docs status](https://img.shields.io/readthedocs/interpreto)](TODO)
104
+ [![Version](https://img.shields.io/pypi/v/interpreto?color=blue)](https://pypi.org/project/interpreto/)
105
+ [![Python Version](https://img.shields.io/pypi/pyversions/interpreto.svg?color=blue)](https://pypi.org/project/interpreto/)
106
+ [![Downloads](https://static.pepy.tech/badge/interpreto)](https://pepy.tech/project/interpreto)
107
+ [![License](https://img.shields.io/github/license/FOR-sight-ai/interpreto)](https://github.com/FOR-sight-ai/interpreto/blob/main/LICENSE)
108
+
109
+ <!-- Link to the documentation -->
110
+ <a href="https://for-sight-ai.github.io/interpreto/"><strong>Explore Interpreto docs Β»</strong></a>
111
+ <br>
112
+
113
+ </div>
114
+
115
+ ## ⚠️ Warning
116
+
117
+ This library is currently in beta and many functions may not work. If you use it anyway, we welcome your comments; please open an issue!
118
+
119
+ The API might change and the documentation is not up to date.
120
+
121
+ In particular, it is not yet possible to obtain interpretable concept-based explanations.
122
+
123
+ ## πŸ“š Table of contents
124
+
125
+ - [πŸ“š Table of contents](#-table-of-contents)
126
+ - [πŸš€ Quick Start](#-quick-start)
127
+ - [πŸ“¦ What's Included](#-whats-included)
128
+ - [πŸ‘ Contributing](#-contributing)
129
+ - [πŸ‘€ See Also](#-see-also)
130
+ - [πŸ™ Acknowledgments](#-acknowledgments)
131
+ - [πŸ‘¨β€πŸŽ“ Creators](#-creators)
132
+ - [πŸ—žοΈ Citation](#️-citation)
133
+ - [πŸ“ License](#-license)
134
+
135
+ ## πŸš€ Quick Start
136
+
137
+ The library should be available on PyPI soon. Try `pip install interpreto` to install it.
138
+
139
+ Otherwise, you can clone the repository and install it locally with `pip install -e .`.
140
+
141
+ And any case, checkout the [attribution walkthrough](https://github.com/FOR-sight-ai/interpreto/tree/main/attribution_walkthrough.ipynb) to get started!
142
+
143
+ ## πŸ“¦ What's Included
144
+
145
+ Interpreto πŸͺ„ provides a modular framework encompassing Attribution Methods, Concept-Based Methods, and Evaluation Metrics.
146
+
147
+ ### Attribution Methods
148
+
149
+ <details>
150
+ <summary>Interpreto includes both inference-based and gradient-based attribution methods:</summary>
151
+
152
+ *We currently have these methods available:*
153
+
154
+ **Inference-based Methods:**
155
+
156
+ - Occlusion: [Zeiler and Fergus, 2014. Visualizing and understanding convolutional networks](https://link.springer.com/chapter/10.1007/978-3-319-10590-1_53).
157
+ - LIME: [Ribeiro et al. 2013, "Why should i trust you?" explaining the predictions of any classifier](https://dl.acm.org/doi/abs/10.1145/2939672.2939778).
158
+ - Kernel SHAP: [Lundberg and Lee, 2017, A Unified Approach to Interpreting Model Predictions](https://arxiv.org/abs/1705.07874).
159
+ - Sobol Attribution: [Fel et al. 2021, Look at the variance! efficient black-box explanations with sobol-based sensitivity analysis](https://proceedings.neurips.cc/paper/2021/hash/da94cbeff56cfda50785df477941308b-Abstract.html).
160
+
161
+ **Gradient based methods:**
162
+
163
+ - Saliency: [Simonyan et al. 2013, Deep Inside Convolutional Networks: Visualising Image Classification Models and Saliency Maps](https://arxiv.org/abs/1312.6034).
164
+ - Integrated Gradient: [Sundararajan et al. 2017, Axiomatic Attribution for Deep Networks](http://proceedings.mlr.press/v70/sundararajan17a.html).
165
+ - SmoothGrad: [Smilkov et al. 2017, SmoothGrad: removing noise by adding noise](https://arxiv.org/abs/1706.03825)
166
+
167
+ *We will be adding these methods soon (Gradient based methods):*
168
+
169
+ - InputxGradient: [Simonyan et al. 2013, Deep Inside Convolutional Networks: Visualising Image Classification Models and Saliency Maps](https://arxiv.org/abs/1312.6034).
170
+ - DeepLift: [Shrikumar et al. 2017, Learning Important Features Through Propagating Activation Differences](http://proceedings.mlr.press/v70/shrikumar17a).
171
+ - VarGrad: [Richter et al. 2020, VarGrad: A Low-Variance Gradient Estimator for Variational Inference](https://proceedings.neurips.cc/paper/2020/hash/9c22c0b51b3202246463e986c7e205df-Abstract.html)
172
+
173
+ </details>
174
+
175
+ ### Concept-Based Methods
176
+
177
+ <details>
178
+
179
+ <summary> Concept-based explanations aim to provide high-level interpretations of latent model representations. </summary>
180
+
181
+ Interpreto generalizes these methods through three core steps:
182
+
183
+ 1. Concept Discovery (e.g., from latent embeddings)
184
+ 2. Concept Interpretation (mapping discovered concepts to human-understandable elements)
185
+ 3. Concept-to-Output Attribution (assessing concept relevance to model outputs)
186
+
187
+ **Concept Discovery Techniques** (via [Overcomplete](https://github.com/KempnerInstitute/overcomplete)):
188
+
189
+ - NMF, Semi-NMF, ConvexNMF
190
+ - ICA, SVD, PCA
191
+ - SAE variants (Vanilla SAE, TopK SAE, JumpReLU SAE, BatchTopK SAE)
192
+
193
+ **Available Concept Interpretation Techniques:**
194
+
195
+ - Top-k tokens from tokenizer vocabulary
196
+
197
+ *Concept Interpretation Techniques Added Soon:*
198
+
199
+ - Top-k tokens/words/clauses/sentences from specific datasets
200
+ - Input-to-concept attribution from dataset examples ([Jourdan et al. 2023](https://aclanthology.org/2023.findings-acl.317/))
201
+ - Theme prediction via LLMs from top-k tokens/sentences
202
+
203
+ *Concept Interpretation Techniques Added Later:*
204
+
205
+ - OpenAI Interpretation ([Bills et al. 2023](https://openai.com/index/language-models-can-explain-neurons-in-language-models/))
206
+ - Aligning concepts with human labels ([Sajjad et al. 2022](https://aclanthology.org/2022.naacl-main.225/))
207
+ - Word cloud visualizations of concepts ([Dalvi et al. 2022](https://arxiv.org/abs/2205.07237))
208
+ - VocabProj & TokenChange ([Gur-Arieh et al. 2025](https://arxiv.org/abs/2501.08319))
209
+
210
+ **Concept-to-Output Attribution:**
211
+
212
+ This part will be implemented later, but all the attribution methods presented above will be available here.
213
+
214
+ *Note that only methods with a concept extraction that has an encoder (input to concept) AND a decoder (concept to output) can use this function.*
215
+
216
+ **Specific methods:**
217
+
218
+ **[Available later when all parts are implemented]** Thanks to this generalization encompassing all concept-based methods and our highly flexible architecture, we can easily obtain a large number of concept-based methods:
219
+
220
+ - CAV and TCAV: [Kim et al. 2018, Interpretability Beyond Feature Attribution: Quantitative Testing with Concept Activation Vectors (TCAV)](http://proceedings.mlr.press/v80/kim18d.html)
221
+ - ConceptSHAP: [Yeh et al. 2020, On Completeness-aware Concept-Based Explanations in Deep Neural Networks](https://proceedings.neurips.cc/paper/2020/hash/ecb287ff763c169694f682af52c1f309-Abstract.html)
222
+ - COCKATIEL: [Jourdan et al. 2023, COCKATIEL: COntinuous Concept ranKed ATtribution with Interpretable ELements for explaining neural net classifiers on NLP](https://aclanthology.org/2023.findings-acl.317/)
223
+ - Yun et al. 2021, [Transformer visualization via dictionary learning: contextualized embedding as a linear superposition of transformer factors](https://arxiv.org/abs/2103.15949)
224
+ - FFN values interpretation: [Geva et al. 2022, Transformer Feed-Forward Layers Build Predictions by Promoting Concepts in the Vocabulary Space](https://aclanthology.org/2022.emnlp-main.3/)
225
+ - SparseCoding: [Cunningham et al. 2023, Sparse Autoencoders Find Highly Interpretable Features in Language Models](https://arxiv.org/abs/2309.08600)
226
+ - Parameter Interpretation: [Dar et al. 2023, Analyzing Transformers in Embedding Space](https://aclanthology.org/2023.acl-long.893/)
227
+
228
+ </details>
229
+
230
+ ### Evaluation Metrics
231
+
232
+ **Evaluation Metrics for Attribution**
233
+
234
+ We don't yet have metrics implemented for attribution methods, but that's coming soon!
235
+
236
+ **Evaluation Metrics for Concepts**
237
+
238
+ <details>
239
+
240
+ <summary> Several properties of the concept-space are desirable. The concept-space should (1) be faithful to the latent space data distribution; (2) have a low complexity to push toward interpretability; (3) be stable across different training regimes.
241
+ </summary>
242
+
243
+ - *Concept-space faithfulness:* In Interpreto, you can use the ReconstructionError to define a custom metric by specifying a reconstruction_space and a distance_function. The MSE or FID metrics are also available.
244
+ - *Concept-space complexity:* Sparsity and SparsityRatio metric are available.
245
+ - *Concept-space stability:* You can use Stability metric to compare concept-model dictionaries.
246
+
247
+ </details>
248
+
249
+ ## πŸ‘ Contributing
250
+
251
+ Feel free to propose your ideas or come and contribute with us on the Interpreto πŸͺ„ toolbox! We have a specific document where we describe in a simple way how to make your [first pull request](docs/contributing.md).
252
+
253
+ ## πŸ‘€ See Also
254
+
255
+ More from the DEEL project:
256
+
257
+ - [Xplique](https://github.com/deel-ai/xplique) a Python library dedicated to explaining neural networks (Images, Time Series, Tabular data) on TensorFlow.
258
+ - [Puncc](https://github.com/deel-ai/puncc) a Python library for predictive uncertainty quantification using conformal prediction.
259
+ - [oodeel](https://github.com/deel-ai/oodeel) a Python library that performs post-hoc deep Out-of-Distribution (OOD) detection on already trained neural network image classifiers.
260
+ - [deel-lip](https://github.com/deel-ai/deel-lip) a Python library for training k-Lipschitz neural networks on TensorFlow.
261
+ - [deel-torchlip](https://github.com/deel-ai/deel-torchlip) a Python library for training k-Lipschitz neural networks on PyTorch.
262
+ - [Influenciae](https://github.com/deel-ai/influenciae) a Python library dedicated to computing influence values for the discovery of potentially problematic samples in a dataset.
263
+ - [DEEL White paper](https://arxiv.org/abs/2103.10529) a summary of the DEEL team on the challenges of certifiable AI and the role of data quality, representativity and explainability for this purpose.
264
+
265
+ ## πŸ™ Acknowledgments
266
+
267
+ This project received funding from the French ”Investing for the Future – PIA3” program within the Artificial and Natural Intelligence Toulouse Institute (ANITI). The authors gratefully acknowledge the support of the [DEEL](https://www.deel.ai) and the FOR projects.
268
+
269
+ ## πŸ‘¨β€πŸŽ“ Creators
270
+
271
+ Interpreto πŸͺ„ is a project of the FOR and the [DEEL](https://www.deel.ai) teams at the [IRT Saint-ExupΓ©ry](https://www.irt-saintexupery.com/) in Toulouse, France.
272
+
273
+ ## πŸ—žοΈ Citation
274
+
275
+ If you use Interpreto πŸͺ„ as part of your workflow in a scientific publication, please consider citing πŸ—žοΈ our paper (coming soon):
276
+
277
+ ```bibtex
278
+ BibTeX entry coming soon
279
+ ```
280
+
281
+ ## πŸ“ License
282
+
283
+ The package is released under [MIT license](LICENSE).