Giter VIP home page Giter VIP logo

trak's Introduction

PyPI version arXiv

[docs & tutorials] [paper] [blog post] [website]

TRAK: Attributing Model Behavior at Scale

In our paper, we introduce a new data attribution method called TRAK (Tracing with the Randomly-Projected After Kernel). Using TRAK, you can make accurate counterfactual predictions (e.g., answers to questions of the form “what would happen to this prediction if these examples are removed from the training set?"). Computing data attribution with TRAK is 2-3 orders of magnitude cheaper than comparably effective methods, e.g., see our evaluation on:

Main figure

Citation

If you use this code in your work, please cite using the following BibTeX entry:

@inproceedings{park2023trak,
  title = {TRAK: Attributing Model Behavior at Scale},
  author = {Sung Min Park and Kristian Georgiev and Andrew Ilyas and Guillaume Leclerc and Aleksander Madry},
  booktitle = {Arxiv preprint arXiv:2303.14186},
  year = {2023}
}

Usage

[Quickstart]

Check our docs for more detailed examples and tutorials on how to use TRAK. Below, we provide a brief blueprint of using TRAK's API to compute attribution scores.

Make a TRAKer instance

from trak import TRAKer

model, checkpoints = ...
train_loader = ...

traker = TRAKer(model=model, task='image_classification', train_set_size=...)

Compute TRAK features on training data

for model_id, checkpoint in enumerate(checkpoints):
  traker.load_checkpoint(ckeckpoint, model_id=model_id)
  for batch in loader_train:
      # batch should be a tuple of inputs and labels
      traker.featurize(batch=batch, ...)
traker.finalize_features()

Compute TRAK scores for target examples

targets_loader = ...

for model_id, checkpoint in enumerate(checkpoints):
  traker.start_scoring_checkpoint(ckeckpoint, model_id=model_id, num_targets=...)
  for batch in targets_loader:
    traker.score(batch=batch, ...)

scores = traker.finalize_scores()

Examples

You can find several end-to-end examples in the examples/ directory.

Installation

To install the version of our package which contains a fast, custom CUDA kernel for the JL projection step, use

pip install traker[fast]

You will need compatible versions of gcc and CUDA toolkit to install it. See the installation FAQs for tips regarding this. To install the basic version of our package that requires no compilation, use

pip install traker

Questions?

Please send an email to [email protected]

Maintainers:

Kristian Georgiev
Andrew Ilyas
Guillaume Leclerc
Sung Min Park

trak's People

Contributors

kristian-georgiev avatar sung-max avatar guillaumeleclerc avatar andrewilyas avatar bencw99 avatar guspan-tanadi 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.