Skip to content

About

First-principles transformer implementation in PyTorch built for interpretability rather than speed — traces the residual stream and K/V attention pathways (6 layers x 32 positions = 2.3 million paths) with a visualization suite, preset configs from debug to xlarge, and tests.

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

First-Principles Transformer

A small, inspectable PyTorch transformer for learning how causal attention and residual updates work. A forward pass can return the tensors used by the analysis and visualization code alongside vocabulary logits. Examples use synthetic token IDs and initialized model weights.

  • Documentation covers setup, model configuration, analysis, visualizations, and verification.
  • Technical manuscript explains the captured state and includes a seeded CPU probe with a figure and numeric checks.
  • Examples contains runnable demonstrations.
  • Citation and license identify the software.

Run the smoke check and tests from the repository root after following the quick start.

python scripts/verify_installation.py
MPLBACKEND=Agg OMP_NUM_THREADS=1 python -m pytest -q

About

First-principles transformer implementation in PyTorch built for interpretability rather than speed — traces the residual stream and K/V attention pathways (6 layers x 32 positions = 2.3 million paths) with a visualization suite, preset configs from debug to xlarge, and tests.

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages