{"library":"sae-lens","title":"SAE Lens","description":"SAE Lens is a library for training, loading, and analyzing sparse autoencoders (SAEs) on transformer language models. Current version is 6.43.0, with frequent releases (multiple versions per month).","language":"python","status":"active","last_verified":"Fri May 01","install":{"commands":["pip install sae-lens"],"cli":null},"imports":["from sae_lens import SAE","from sae_lens.config import SAEConfig","from sae_lens import HookedSAETransformer"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"from sae_lens import SAE\nfrom transformer_lens import HookedTransformer\n\nmodel = HookedTransformer.from_pretrained(\"gpt2-small\", device=\"cpu\")\nsae, cfg_dict, sparsity = SAE.from_pretrained(release=\"gpt2-small-res-jb\", sae_id=\"blocks.0.hook_resid_pre\", device=\"cpu\")\nsae.to(\"cpu\")\n\n# Example: get SAE feature activations for a prompt\nprompt = \"Hello, world!\"\n_, cache = model.run_with_cache(prompt, names_filter=[sae.cfg.hook_name])\nact = cache[sae.cfg.hook_name]\nsae_acts = sae.encode(act)\nprint(sae_acts.shape)\n","lang":"python","description":"Load a pretrained SAE and compute feature activations for a prompt.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}