Surgical unlearning of classes, concepts, and facts in any PyTorch model
Project description
ai-engram
Surgical unlearning of classes, concepts, and facts in any PyTorch model.
ai-engram identifies the directions in a network's weights that store
specific information — a class, a concept, a fact — and edits them out
in closed form, with no gradient descent. It works on Linear,
Conv1d, and Conv2d layers (grouped and depthwise convolutions
included) and has been verified end-to-end against 24 pretrained
vision, language, and diffusion models.
Installation
pip install ai-engram
Quickstart
import torch
import torch.nn as nn
from torch.utils.data import DataLoader, TensorDataset
from ai_engram import EditorConfig, EngramEditor
model = nn.Sequential(nn.Linear(8, 16), nn.ReLU(), nn.Linear(16, 4))
forget_loader = DataLoader(TensorDataset(torch.randn(32, 8)), batch_size=8)
total_loader = DataLoader(TensorDataset(torch.randn(128, 8)), batch_size=8)
editor = EngramEditor(model, EditorConfig(device="cpu", damping_factor=1e-3))
forget_cov = editor.collect_statistics(forget_loader)
total_cov = editor.collect_statistics(total_loader)
edited = editor.edit(forget_cov, total_cov)
forget_cov carries the second-moment statistics of the data you want
the model to forget; total_cov carries the statistics of the full
training distribution. The edit removes the projection of the weights
onto the forget subspace while preserving the rest.
This exact snippet is executed in CI on every commit and on every
release, so a pip install always produces a runnable library.
Documentation
Full guides, API reference, and the 24-model compatibility report live at https://jeakwon.github.io/ai-engram/.
License
MIT — see also CHANGELOG.md.
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 ai_engram-0.1.0.tar.gz.
File metadata
- Download URL: ai_engram-0.1.0.tar.gz
- Upload date:
- Size: 16.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9717a5a33755846f2a99a98b609c9f5e900958cf7f6dd2fc1aacbc6a2cddc414
|
|
| MD5 |
64003a3257305142d91156fe3dee2d5e
|
|
| BLAKE2b-256 |
5d384bef708644f2e65bdc98013dd386dd610ded1c14f03833ab8c1e7e42ba23
|
Provenance
The following attestation bundles were made for ai_engram-0.1.0.tar.gz:
Publisher:
publish.yml on jeakwon/ai-engram
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ai_engram-0.1.0.tar.gz -
Subject digest:
9717a5a33755846f2a99a98b609c9f5e900958cf7f6dd2fc1aacbc6a2cddc414 - Sigstore transparency entry: 1624917353
- Sigstore integration time:
-
Permalink:
jeakwon/ai-engram@8ed8877954726373e0ce9e8ac341dcf0d93a6313 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/jeakwon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8ed8877954726373e0ce9e8ac341dcf0d93a6313 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ai_engram-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ai_engram-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b423dafc46892a787abdaa44c9f83b9ad31d929bec55888b7d846feb78bf5a5
|
|
| MD5 |
e9f5e84f300d4bd2ccf79347196ad9a6
|
|
| BLAKE2b-256 |
ed8aab5ff695b232637440e02611e2ca49e5aab7040b81ff646c45c2e6da9e4d
|
Provenance
The following attestation bundles were made for ai_engram-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on jeakwon/ai-engram
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ai_engram-0.1.0-py3-none-any.whl -
Subject digest:
5b423dafc46892a787abdaa44c9f83b9ad31d929bec55888b7d846feb78bf5a5 - Sigstore transparency entry: 1624917358
- Sigstore integration time:
-
Permalink:
jeakwon/ai-engram@8ed8877954726373e0ce9e8ac341dcf0d93a6313 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/jeakwon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8ed8877954726373e0ce9e8ac341dcf0d93a6313 -
Trigger Event:
push
-
Statement type: