A package for mechanistic understanding and validation of large AI model with SemanticLens
Project description
An open-source pytorch implementation of SemanticLens.
Installation
pip install semanticlens
Quickstart
import semanticlens as sl
# step 1 - preprocess component-visualizations
act_cv = sl.component_visualization.ActivationComponentVisualizer(
model,
dataset,
layer_names,
)
act_cv.run(batch_size=128, num_workers=16)
# step 2 - compute semantic embeddings
fm = sl.foundation_models.OpenClip("hf-hub:apple/MobileCLIP-S2-OpenCLIP")
lens = sl.Lens(
dataset=dataset,
component_visualizer=act_cv,
foundation_model=fm,
)
lens.compute_semantic_embeddigs(layer_names)
# step 3 - inspect, search, label, evaluate, ...
lens.label(
["wall", "small", "sky", "floor", "red",...],
templates=["a natural image showing {}"],
) # ("layer3", 95): "brown vegetation" ,...
lens.search("watermark") # ("layer4", [63, 21, 362]), ...
lens.evaluate_clarity() # {"layer4" : [[0.64, 0.32, ... ]]}
Project status
Note
The project is currently under active development. 🛠️
Please expect interfaces to change.
The state of development will be updated here.
Contributing
We adhere to the PEP8 standard with a maximum line width of 120 characters.
For linting and style checks, we use ruff, configured to enforce PEP8 compliance along with additional rules.
Our basic tests are implemented using pytest.
License
BSD 3-Clause Clear License
Citation
@article{dreyer2025mechanistic,
title={Mechanistic understanding and validation of large AI models with SemanticLens},
author={Dreyer, Maximilian and Berend, Jim and Labarta, Tobias and Vielhaben, Johanna and Wiegand, Thomas and Lapuschkin, Sebastian and Samek, Wojciech},
journal={arXiv preprint arXiv:2501.05398},
year={2025}
}
Project details
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 semanticlens-0.1.0.tar.gz.
File metadata
- Download URL: semanticlens-0.1.0.tar.gz
- Upload date:
- Size: 12.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d755e26490712bdbe70bab2d012c19d922b025b820abbba27a7de4cf6a77d5a
|
|
| MD5 |
23a9c8d275cbd6556b219849c5426b90
|
|
| BLAKE2b-256 |
73bc0b9fc28e8d0167a4e8b992f8d8d677d00a0eb15eac9ab16f1265f7ab00a9
|
Provenance
The following attestation bundles were made for semanticlens-0.1.0.tar.gz:
Publisher:
python-publish.yml on jim-berend/semanticlens
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
semanticlens-0.1.0.tar.gz -
Subject digest:
2d755e26490712bdbe70bab2d012c19d922b025b820abbba27a7de4cf6a77d5a - Sigstore transparency entry: 198393521
- Sigstore integration time:
-
Permalink:
jim-berend/semanticlens@706cb6f61ba2bcf9d08df68b606ab126e339ee4d -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/jim-berend
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@706cb6f61ba2bcf9d08df68b606ab126e339ee4d -
Trigger Event:
release
-
Statement type:
File details
Details for the file semanticlens-0.1.0-py3-none-any.whl.
File metadata
- Download URL: semanticlens-0.1.0-py3-none-any.whl
- Upload date:
- Size: 23.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee08868a5565224b936f68294bdcb10de071058f1da7309f606a43b6d23cc3aa
|
|
| MD5 |
a4d5e96464cd4f47e157d3832760b63c
|
|
| BLAKE2b-256 |
2b5b8f4bf9be351203c47d81f981bbc652afc98f6f5ff55f3de7b0f46bd4339a
|
Provenance
The following attestation bundles were made for semanticlens-0.1.0-py3-none-any.whl:
Publisher:
python-publish.yml on jim-berend/semanticlens
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
semanticlens-0.1.0-py3-none-any.whl -
Subject digest:
ee08868a5565224b936f68294bdcb10de071058f1da7309f606a43b6d23cc3aa - Sigstore transparency entry: 198393523
- Sigstore integration time:
-
Permalink:
jim-berend/semanticlens@706cb6f61ba2bcf9d08df68b606ab126e339ee4d -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/jim-berend
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@706cb6f61ba2bcf9d08df68b606ab126e339ee4d -
Trigger Event:
release
-
Statement type: