Giter VIP home page Giter VIP logo

llm-context-neurons's Introduction

llm-context-neurons

A minimal replication of finding context neurons in Pythia models. See Finding Neurons in a Haystack: Case Studies with Sparse Probing for more details.

The results of this repo are available in the context_neurons directory.

Instructions

This repo contains two datasets: europarl_lang and pile_data_source containing samples of parliment documents in many different European languages, and samples of the Pile dataset from different subdistributions.

After installing the required dependencies, save activations for any of the pythia models via

python activations.py --model pythia-70m --feature_dataset pile_data_source
python activations.py --model pythia-70m --feature_dataset europarl_lang

Then, run the following to find context neurons:

python find_context_neurons.py --model pythia-70m --feature_dataset pile_data_source
python find_context_neurons.py --model pythia-70m --feature_dataset europarl_lang

This will dump a csv containing the top 10 most predictive neurons for each context feature in the dataset. Precomputed results are available in the context_neurons directory.

Caveats

  • Assumes you can store all activations in CPU RAM before caching
  • Datasets are tokenized according to the pythia tokenizer so this won't work for other model families without modifying the datasets.

Cite

If this was helpful, please cite our work:

@article{gurnee2023finding,
  title={Finding Neurons in a Haystack: Case Studies with Sparse Probing},
  author={Gurnee, Wes and Nanda, Neel and Pauly, Matthew and Harvey, Katherine and Troitskii, Dmitrii and Bertsimas, Dimitris},
  journal={arXiv preprint arXiv:2305.01610},
  year={2023}
}

llm-context-neurons's People

Contributors

wesg52 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

edk208

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.