Metadata-Version: 2.1
Name: devinterp
Version: 0.0.2
Summary: A library for doing research on developmental interpretability
Project-URL: Homepage, https://github.com/timaeus-research/devinterp
Project-URL: Bug Tracker, https://github.com/timaeus-research/devinterp/issues
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: einops==0.6.1
Requires-Dist: ipykernel==5.5.6
Requires-Dist: ipywidgets==8.0.7
Requires-Dist: jupyter_core==5.3.1
Requires-Dist: jupyterlab-widgets==3.0.8
Requires-Dist: numpy==1.23.5
Requires-Dist: pandas==1.5.3
Requires-Dist: pydantic==2.1.1
Requires-Dist: pydantic_core==2.4.0
Requires-Dist: torch==2.0.1
Requires-Dist: torchtyping==0.1.4
Requires-Dist: tqdm==4.65.0
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: moto[all,ec2,s3]; extra == "dev"

# DevInterp

[![PyPI version](https://badge.fury.io/py/devinterp.svg)](https://badge.fury.io/py/devinterp) ![Python version](https://img.shields.io/pypi/pyversions/devinterp) ![Contributors](https://img.shields.io/github/contributors/timaeus-research/devinterp)



## A Python Library for Developmental Interpretability Research

DevInterp is a python library for conducting research on developmental interpretability, a novel AI safety research agenda rooted in Singular Learning Theory (SLT). DevInterp proposes tools for detecting, locating, and ultimately _controlling_ the development of structure over training.

[Read more about developmental interpretability](https://www.lesswrong.com/posts/TjaeCWvLZtEDAS5Ex/towards-developmental-interpretability).

> :warning: This library is still in early development. Don't expect things to work on a first attempt. We are actively working on improving the library and adding new features. If you have any questions or suggestions, please feel free to open an issue or submit a pull request.

## Installation

To install `devinterp`, simply run:

```bash
pip install devinterp
```

**Requirements**: Python 3.8 or higher.

## Getting Started

To see DevInterp in action, check out our example notebooks:


- [Introduction](https://www.github.com/timaeus-research/devinterp/blob/main/examples/introduction.ipynb) [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/timaeus-research/devinterp/blob/main/examples/introduction.ipynb)
- [Normal Crossing Demo](https://www.github.com/timaeus-research/devinterp/blob/main/examples/normal_crossing.ipynb) [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/timaeus-research/devinterp/blob/main/examples/normal_crossing.ipynb)
- [MNIST Demo](https://www.github.com/timaeus-research/devinterp/blob/main/examples/mnist.ipynb) [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/timaeus-research/devinterp/blob/main/examples/mnist.ipynb)
- [Deep Linear Networks](https://www.github.com/timaeus-research/devinterp/blob/main/examples/dlns.ipynb) [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/timaeus-research/devinterp/blob/main/examples/dlns.ipynb)
- [Toy Models of Superposition](https://www.github.com/timaeus-research/devinterp/blob/main/examples/tms.ipynb) [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/timaeus-research/devinterp/blob/main/examples/tms.ipynb)


### Minimal Example

```python
from devinterp.slt import estimate_learning_coeff, estimate_learning_coeff_with_summary
from devinterp.optim import SGLD

# Assuming you have a PyTorch Module and DataLoader
learning_coeff = estimate_learning_coeff(model, trainloader, ...)

# If you want to see mean, std, and learning coeff estimate per chain
learning_coeff_summary = estimate_learning_coeff_with_summary(model, trainloader, ...)

```

## Features

- Estimate the learning coefficient.
  - Supported optimizers: 
    - [`SGLD`](https://www.github.com/timaeus-research/devinterp/blob/main/src/devinterp/optim/sgld.py)
    - [`SGNHT`](https://www.github.com/timaeus-research/devinterp/blob/main/src/devinterp/optim/sgnht.py)

## Contributing

See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines on how to contribute.
