Metadata-Version: 2.4
Name: ai-engram
Version: 0.3.0
Summary: Surgical unlearning of classes, concepts, and facts in any PyTorch model
Author-email: Jea Kwon <onlytojay@gmail.com>
Maintainer-email: Jea Kwon <onlytojay@gmail.com>
License: MIT License
        
        Copyright (c) 2026 Jea Kwon
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/jeakwon/ai-engram
Project-URL: Documentation, https://jeakwon.github.io/ai-engram/
Project-URL: Repository, https://github.com/jeakwon/ai-engram
Project-URL: Issues, https://github.com/jeakwon/ai-engram/issues
Project-URL: Changelog, https://github.com/jeakwon/ai-engram/blob/main/CHANGELOG.md
Keywords: deep-learning,pytorch,model-editing,machine-unlearning,neural-network
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: <3.13,>=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: torch<3.0,>=2.0.0
Requires-Dist: numpy>=1.24.0
Requires-Dist: tqdm>=4.60.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Requires-Dist: ruff>=0.6.0; extra == "dev"
Requires-Dist: pre-commit>=3.5; extra == "dev"
Requires-Dist: build>=1.0; extra == "dev"
Requires-Dist: twine>=5.0; extra == "dev"
Provides-Extra: docs
Requires-Dist: mkdocs-material>=9.0; extra == "docs"
Requires-Dist: mkdocstrings[python]>=0.24.0; extra == "docs"
Dynamic: license-file

# ai-engram

**Surgical unlearning of classes, concepts, and facts in any PyTorch model.**

[![PyPI version](https://img.shields.io/pypi/v/ai-engram.svg)](https://pypi.org/project/ai-engram/)
[![Python versions](https://img.shields.io/pypi/pyversions/ai-engram.svg)](https://pypi.org/project/ai-engram/)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![CI](https://github.com/jeakwon/ai-engram/actions/workflows/ci.yml/badge.svg)](https://github.com/jeakwon/ai-engram/actions/workflows/ci.yml)
[![Docs](https://img.shields.io/badge/docs-online-success.svg)](https://jeakwon.github.io/ai-engram/)

`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

```bash
pip install ai-engram
```

## Quickstart

```python
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"))

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](LICENSE) — see also [CHANGELOG.md](CHANGELOG.md).
