penzai  by google-deepmind

JAX research toolkit for neural network building, editing, and visualization

Created 1 year ago
1,836 stars

Top 23.4% on SourcePulse

GitHubView on GitHub
Project Summary

Penzai is a JAX research toolkit designed for building, visualizing, and manipulating neural networks as functional pytree data structures. It targets researchers and engineers focused on model interpretability, ablation studies, and debugging, offering a declarative approach to model construction and modification.

How It Works

Penzai leverages JAX's pytree capabilities to represent neural networks as data structures, enabling programmatic inspection and modification. Key components include Treescope for enhanced pretty-printing of nested data, penzai.core.selectors for powerful pytree traversal and manipulation, and penzai.core.named_axes for a flexible named axis system that integrates seamlessly with JAX. The penzai.nn module provides a combinator-based API for defining models, supporting mutable state and parameter sharing at leaves.

Quick Start & Requirements

  • Install via pip: pip install penzai
  • Requires JAX installation (platform-dependent).
  • Recommended for Colab/IPython: treescope.basic_interactive_setup(autovisualize_arrays=True)
  • Documentation: https://penzai.readthedocs.io

Highlighted Details

  • Declarative neural network library with support for mutable state and parameter sharing.
  • Built-in support for loading and manipulating weights for Gemma, Llama, Mistral, and GPT-NeoX/Pythia architectures.
  • penzai.core.selectors offers generalized .at[...].set() functionality for complex pytree rewrites.
  • penzai.core.named_axes allows seamless switching between named and positional array indexing.

Maintenance & Community

  • This is not an officially supported Google product.
  • Citation available for research use: Johnson, Daniel D. "Penzai + Treescope: A Toolkit for Interpreting, Visualizing, and Editing Models As Data." ICML 2024 Workshop on Mechanistic Interpretability.

Licensing & Compatibility

  • License details are not explicitly stated in the README.

Limitations & Caveats

Penzai v0.2 introduced breaking changes to the neural network API, with a V2 API focusing on mutable state and parameter sharing. Users of the V1 API can access older behavior via penzai.deprecated.v1.

Health Check
Last Commit

6 months ago

Responsiveness

1 week

Pull Requests (30d)
0
Issues (30d)
0
Star History
10 stars in the last 30 days

Explore Similar Projects

Starred by Wes McKinney Wes McKinney(Author of Pandas), Edward Sun Edward Sun(Research Scientist at Meta Superintelligence Lab), and
2 more.

grain by google

0.5%
646
Python library for ML training data pipelines
Created 3 years ago
Updated 1 day ago
Starred by George Hotz George Hotz(Author of tinygrad; Founder of the tiny corp, comma.ai), Patrick von Platen Patrick von Platen(Author of Hugging Face Diffusers; Research Engineer at Mistral), and
6 more.

jaxtyping by patrick-kidger

0.6%
2k
Typing library for array shapes/dtypes
Created 3 years ago
Updated 6 days ago
Starred by Chip Huyen Chip Huyen(Author of "AI Engineering", "Designing Machine Learning Systems"), Pawel Garbacki Pawel Garbacki(Cofounder of Fireworks AI), and
6 more.

tianshou by thu-ml

0.1%
9k
PyTorch RL library for algorithm development and application
Created 7 years ago
Updated 1 month ago
Feedback? Help us improve.