Upload README.md with huggingface_hub
Browse files1234567891011121314151617181920212223242526272829303132333435363738---license: mitlibrary_name: transformer-lenstags: [mechanistic-interpretability, induction-heads, toy-model, transformer-circuits, visualization]---
# transformer-visualized: tiny 2-layer transformers (trained, hand-crafted, controls)
Weights for **[transformer-visualized](https://github.com/BurnyCoder/transformer-visualized)**, an interactive, animated visualization of a two-layertransformer (live site: https://burnycoder.github.io/transformer-visualized/). Every run of the preregistered study is here under `runs/<run_id>/`:
- `final.safetensors`: final weights (TransformerLens 3.9.0 `HookedTransformer` names; biases are zero and omitted)- `checkpoints/step_*.safetensors`: ~40 log-spaced training checkpoints- `config.json`: architecture and training spec- `metrics.jsonl`: validation metrics logged during training- `eval_val.json` / `eval_test.json`: full evaluation (losses with bootstrap CIs, G, head scores, circuits, ablations)
**Architecture.** 2 layers, 2 heads × 8 dims, ReLU MLP of width 64, d_model = 32, n_ctx = 24, vocabulary of 26words; no LayerNorm, zero biases (the simplifications of *A Mathematical Framework for Transformer Circuits*).
**Data.** A toy word grammar (exact bigram chain) in which each later sentence repeats an earlier one withprobability 0.5. The splits are in the companion dataset repo.
**Key results (test set).** Gain fraction G (share of the achievable in-context gain; 0 = bigram oracle,1 = Bayes-optimal): main 2-layer model 0.981 [0.971, 0.990] over 5 seeds; hand-crafted 0.853 [0.851, 0.855].
**Load.**```pythonfrom transformer_lens import HookedTransformer, HookedTransformerConfigfrom safetensors.torch import load_filecfg = HookedTransformerConfig(n_layers=2, d_model=32, n_ctx=24, d_head=8, n_heads=2, d_mlp=64, d_vocab=26, act_fn="relu", normalization_type=None)model = HookedTransformer(cfg)model.load_state_dict(load_file("runs/main_s0/final.safetensors"), strict=False) # biases stay zero```Token ids: see `src/tfviz/grammar.py` in the code repository (0 = `<bos>`, 1 = `.`).
Author: Libor "Burny" Burian. License: MIT.README.mdAdded+38