Giter Club home page Giter Club logo

devinterp's Introduction

DevInterp

PyPI version Python version Contributors Docs

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.

โš ๏ธ 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.

Installation

To install devinterp, simply run pip install devinterp.

Minimal Example

from devinterp.slt import sample, LLCEstimator
from devinterp.optim import SGLD
from devinterp.utils import optimal_temperature

# Assuming you have a PyTorch Module and DataLoader
llc_estimator = LLCEstimator(..., temperature=optimal_temperature(trainloader))
sample(model, trainloader, ..., callbacks = [llc_estimator])

llc_mean = llc_estimator.sample()["llc/mean"]

Advanced Usage

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

For more advanced usage, see the Diagnostics notebook Open In Colab and for a quick guide on picking hyperparameters, see the Calibration notebook. Open In Colab. Documentation can be found here. Docs

For papers that either inspired or used the DevInterp package, click here.

Known Issues

  • The current implementation does not work with transformers out-of-the-box. This can be fixed by adding a wrapper to your model, for example passing Unpack(model) to sample() where unpack is defined by:
class Unpack(nn.Module):
 def __init__(model: nn.Module):
      self.model = model

 def forward(data: Tuple[torch.Tensor, torch.Tensor]):
      return self.model(*data)
  • LLC Estimation is currently more of an art than a science. It will take some time and pain to get it work reliably.

If you run into issues not mentioned here, please first check the github issues, then ask in the DevInterp Discord, and only then make a new github issue.

Contributing

See CONTRIBUTING.md for guidelines on how to contribute.

Credits & Citations

This package was created by Timaeus. The main contributors to this package are Jesse Hoogland, Stan van Wingerden, and George Wang. Zach Furman, Matthew Farrugia-Roberts and Edmund Lau also made valuable contributions or provided useful advice.

If this package was useful in your work, please cite it as:

   @misc{devinterp2024,
      title = {DevInterp},
      author = {Jesse Hoogland, Stan van Wingerden, and George Wang},
      year = {2024},
      howpublished = {\url{https://github.com/timaeus-research/devinterp}},
   }

devinterp's People

Contributors

dmurfet avatar georgeyw avatar jasongross avatar jqhoogland avatar matomatical avatar svwingerden avatar zfurman56 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.