https://github.com/google-deepmind/mishax
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.6%) to scientific vocabulary
Repository
Basic Info
- Host: GitHub
- Owner: google-deepmind
- License: apache-2.0
- Language: Python
- Default Branch: main
- Size: 73.2 KB
Statistics
- Stars: 134
- Watchers: 8
- Forks: 8
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
Mishax
Introduction
Mishax is a utility library for mechanistic interpretability research, with its motivations explained in this blog post. It enables users to do 2 things:
mishax.ast_patcher enables running code from some other library (e.g. a deep learning codebase) with some source-level code modifications applied. For mechanistic interpretability this can be used to stick probes in the model and intervene at arbitrary locations. This otherwise requires forking the code that’s being modified, but that comes with more maintenance requirements.
mishax.safe_greenlet, given a complicated function f that allows running arbitrary callbacks somewhere deep inside (e.g. using Flax’s intercept_methods), enables transforming it into an ordinary-looking Python for loop that iterates over internal values and allows them to be replaced with other values. Behind the scenes, this will run f in a kind of separate “thread” –- but the user can mostly ignore that, and use the loop to read and write representations into the model during a forward pass, in a way that interoperates well with the rest of JAX.
In mishax.examples.gemma you can find an example of instrumenting an LLM codebase; it's pointed at the https://github.com/google-deepmind/gemma reference implementation of Gemma.
Note
ast_patcher relies on code transformations of the target code, which violates some usual abstractions. Careless use may reduce codebase maintainability -- AST patching is best deployed in moderation and with care. For more details, see the ModuleASTPatcher docstring.
Setup
shell
python3 -m venv $HOME/mishax-venv
source $HOME/mishax-venv/bin/activate
python3 -m pip install git+git://github.com/google-deepmind/mishax.git
With deps for the Gemma example:
shell
python3 -m venv $HOME/mishax-venv
source $HOME/mishax-venv/bin/activate
python3 -m pip install git+git://github.com/google-deepmind/mishax.git[gemma]
To deactivate the virtual environment, run deactivate.
Run tests
shell
source $HOME/mishax-venv/bin/activate
python3 -m pip install git+git://github.com/google-deepmind/mishax.git[dev]
python3 -m mishax.ast_patcher_test
python3 -m mishax.safe_greenlet_test
python3 -m mishax.examples.gemma_test
Colab Tutorial
A colab notebook demonstrating how to instrument Gemma internals with mishax is available here: colab link
Owner
- Name: Google DeepMind
- Login: google-deepmind
- Kind: organization
- Website: https://www.deepmind.com/
- Repositories: 245
- Profile: https://github.com/google-deepmind
GitHub Events
Total
- Watch event: 41
- Delete event: 1
- Member event: 1
- Push event: 9
- Pull request event: 1
- Fork event: 4
- Create event: 1
Last Year
- Watch event: 41
- Delete event: 1
- Member event: 1
- Push event: 9
- Pull request event: 1
- Fork event: 4
- Create event: 1
Committers
Last synced: 10 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Janos Kramar | j****k@g****m | 15 |
| Nicolas Sonnerat | s****t@g****m | 2 |
| Mishax Team | n****y@g****m | 1 |
| Etienne Pot | e****t@g****m | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 10 months ago
All Time
- Total issues: 1
- Total pull requests: 0
- Average time to close issues: 3 days
- Average time to close pull requests: N/A
- Total issue authors: 1
- Total pull request authors: 0
- Average comments per issue: 2.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 1
- Pull requests: 0
- Average time to close issues: 3 days
- Average time to close pull requests: N/A
- Issue authors: 1
- Pull request authors: 0
- Average comments per issue: 2.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- tigerneil (1)
Pull Request Authors
- dependabot[bot] (1)
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- greenlet *
- immutabledict *
- actions/checkout v4 composite
- actions/setup-python v5 composite
- lukka/get-cmake latest composite