neurox

A Python library that encapsulates various methods for neuron interpretation and analysis in Deep NLP models.

https://github.com/fdalvi/neurox

Science Score: 10.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    1 of 6 committers (16.7%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (20.0%) to scientific vocabulary

Keywords

explainable-ai natural-language-processing neurons nlp nlp-machine-learning
Last synced: 6 months ago · JSON representation

Repository

A Python library that encapsulates various methods for neuron interpretation and analysis in Deep NLP models.

Basic Info
  • Host: GitHub
  • Owner: fdalvi
  • License: bsd-3-clause
  • Language: Python
  • Default Branch: master
  • Homepage: https://neurox.qcri.org
  • Size: 1.83 MB
Statistics
  • Stars: 103
  • Watchers: 5
  • Forks: 26
  • Open Issues: 22
  • Releases: 0
Topics
explainable-ai natural-language-processing neurons nlp nlp-machine-learning
Created over 7 years ago · Last pushed over 2 years ago
Metadata Files
Readme Changelog Contributing License

README.md

NeuroX Toolkit

Tests Runner API Reference

NeuroX provide all the necessary tooling to perform Interpretation and Analysis of (Deep) Neural Networks centered around Probing. Specifically, the toolkit provides:

  • Support for extraction of activation from popular models including the entirety of transformers, with extended support for other models like OpenNMT-py planned in the near future
  • Support for training linear probes on top of these activations, on the entire activation space of a model, on specific layers, or even on specific set of neurons.
  • Support for neuron extraction related to specific concepts, using the Linear Correlation Analysis method (What is one Grain of Sand in the Desert? Analyzing Individual Neurons in Deep NLP Models.). The toolkit can extract either a local ranking of neurons important to a particular target class, or a global ranking of neurons important to all the target classes.
  • Support for ablation analysis by either removing or zeroing out specific neurons to determine their function and importance.
  • Support for subword and character level aggregation across a variety of tokenizers, including BPE and all tokenizers in the transformers library.
  • Support for activation visualization over regular text, to generate qualitative samples of neuron activity over particular sentences.

A demo using a lot of functionality provided by this toolkit is available.

demo picture

Getting Started

This toolkit requires and is tested on Python versions 3.6 and above. It may work with older Python versions with some fiddling, but is currently not tested nor supported. The easiest way to get started is to use the published pip package:

```bash pip install neurox

```

Manual Installation

If you wish to install this package manually (e.g. to modify or contribute to the code base), you can clone this repository into a directory of your choice:

bash git clone https://github.com/fdalvi/NeuroX.git

Create and activate a new virtual environment for the toolkit (This step can be skipped if you manage your environment in other ways like Conda or System-level installations):

bash python -m venv .neurox-env source .neurox-env/bin/activate

Install the dependencies required to run the toolkit:

bash pip install -e .

Sample Code

A Jupyter notebook with a complete example of extracting activations from BERT, training a toy task, extracting neurons and visualizing them is available in the examples directory for a quick introduction to the main functionality provided by this toolkit.

Documentation

API Reference contains an API reference for all of the functions exposed by this toolkit. Primarily, the toolkit's functionality is separated into several high-level components:

  • Extraction
  • Data Preprocessing
  • Linear Probing
  • Neuron extraction and interpretation
  • Neuron cluster analysis
  • Visualization

Citation

Please cite our paper published at AAAI'19 if you use this toolkit.

@article{dalvi2019neurox, title={NeuroX: A Toolkit for Analyzing Individual Neurons in Neural Networks}, author={Dalvi, Fahim and Nortonsmith, Avery and Bau, D Anthony and Belinkov, Yonatan and Sajjad, Hassan and Durrani, Nadir and Glass, James}, journal={Proceedings of the AAAI Conference on Artificial Intelligence (AAAI)}, year={2019} }

Planned features

  • [x] Pip package
  • [ ] Support for OpenNMT-py models
  • [ ] Support for control tasks and computing metrics like selectivity
  • [ ] Support for attention and other module analysis

Publications

Owner

  • Name: Fahim Dalvi
  • Login: fdalvi
  • Kind: user

https://fdalvi.github.io

GitHub Events

Total
  • Issues event: 1
  • Watch event: 8
Last Year
  • Issues event: 1
  • Watch event: 8

Committers

Last synced: about 1 year ago

All Time
  • Total Commits: 132
  • Total Committers: 6
  • Avg Commits per committer: 22.0
  • Development Distribution Score (DDS): 0.068
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Fahim Imaduddin Dalvi f****n@h****a 123
Hassan Sajjad h****s@g****m 3
davidarps 3****s 2
Fan Yimin 4****3 2
Nadir Durrani a****i@g****m 1
Yifan Zhang f****n@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 21
  • Total pull requests: 30
  • Average time to close issues: 2 months
  • Average time to close pull requests: about 1 month
  • Total issue authors: 14
  • Total pull request authors: 8
  • Average comments per issue: 1.38
  • Average comments per pull request: 0.43
  • Merged pull requests: 16
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 1
  • Pull request authors: 0
  • Average comments per issue: 0.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • fdalvi (5)
  • Andrea-de-Varda (3)
  • ahmed451 (2)
  • ccliu2 (1)
  • xuemin-yu (1)
  • aprzez (1)
  • Hellisotherpeople (1)
  • davidarps (1)
  • baselmousi (1)
  • hsajjad (1)
  • oserikov (1)
  • yikang0131 (1)
  • alephpi (1)
  • nadirdurrani (1)
Pull Request Authors
  • fdalvi (6)
  • baselmousi (5)
  • fym0503 (5)
  • yifan (4)
  • hsajjad (4)
  • davidarps (3)
  • nadirdurrani (2)
  • sherinrasheed (1)
Top Labels
Issue Labels
enhancement (3) good first issue (2) bug (2)
Pull Request Labels

Packages

  • Total packages: 3
  • Total downloads:
    • pypi 28 last-month
  • Total dependent packages: 0
    (may contain duplicates)
  • Total dependent repositories: 1
    (may contain duplicates)
  • Total versions: 13
  • Total maintainers: 1
proxy.golang.org: github.com/fdalvi/NeuroX
  • Versions: 4
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.5%
Average: 5.7%
Dependent repos count: 5.8%
Last synced: 6 months ago
proxy.golang.org: github.com/fdalvi/neurox
  • Versions: 4
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.5%
Average: 5.7%
Dependent repos count: 5.8%
Last synced: 6 months ago
pypi.org: neurox

Toolkit for Neuron Analysis in Deep NLP Models

  • Versions: 5
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 28 Last month
Rankings
Stargazers count: 7.9%
Forks count: 8.4%
Dependent packages count: 10.0%
Average: 15.5%
Dependent repos count: 21.7%
Downloads: 29.5%
Maintainers (1)
Last synced: 6 months ago

Dependencies

.github/workflows/code-formatting.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v2 composite
.github/workflows/python-36-tests.yaml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
.github/workflows/python-package.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
docs/requirements.txt pypi
  • sphinx-book-theme *
pyproject.toml pypi