diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 1dde6c726..e2b6dfd82 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -223,7 +223,7 @@ jobs: fail-fast: false matrix: notebook: - # - "Activation_Patching_in_TL_Demo" + - "Activation_Patching_in_TL_Demo" # - "Attribution_Patching_Demo" - "ARENA_Content" - "BERT" diff --git a/demos/Activation_Patching_in_TL_Demo.ipynb b/demos/Activation_Patching_in_TL_Demo.ipynb index abc033ad7..98e554445 100644 --- a/demos/Activation_Patching_in_TL_Demo.ipynb +++ b/demos/Activation_Patching_in_TL_Demo.ipynb @@ -40,17 +40,9 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Running as a Jupyter notebook - intended for development only!\n" - ] - } - ], + "outputs": [], "source": [ "# Janky code to do different setup when run in a Colab notebook vs VSCode\n", "DEBUG_MODE = False\n", @@ -58,7 +50,7 @@ " import google.colab\n", " IN_COLAB = True\n", " print(\"Running as a Colab notebook\")\n", - " %pip install git+https://github.com/TransformerLensOrg/TransformerLens.git\n", + " %pip install transformer_lens\n", " # Install my janky personal plotting utils\n", " %pip install git+https://github.com/neelnanda-io/neel-plotly.git\n", "except:\n", @@ -67,7 +59,7 @@ " from IPython import get_ipython\n", "\n", " ipython = get_ipython()\n", - " # Code to automatically update the HookedTransformer code as its edited without restarting the kernel\n", + " # Code to automatically update the TransformerBridge code as its edited without restarting the kernel\n", " ipython.run_line_magic(\"load_ext\", \"autoreload\")\n", " ipython.run_line_magic(\"autoreload\", \"2\")" ] @@ -127,11 +119,7 @@ "source": [ "import transformer_lens\n", "import transformer_lens.utils as utils\n", - "from transformer_lens.hook_points import (\n", - " HookedRootModule,\n", - " HookPoint,\n", - ") # Hooking utilities\n", - "from transformer_lens import HookedTransformer, HookedTransformerConfig, FactoredMatrix, ActivationCache" + "from transformer_lens.model_bridge import TransformerBridge" ] }, { @@ -175,7 +163,14 @@ "metadata": {}, "outputs": [], "source": [ - "from neel_plotly import line, imshow, scatter" + "try:\n", + " from neel_plotly import line, imshow, scatter\n", + "except ImportError:\n", + " # neel_plotly is an optional visualization dependency.\n", + " # Define no-op stubs so patching computations still run without it.\n", + " def line(*args, **kwargs): pass\n", + " def imshow(*args, **kwargs): pass\n", + " def scatter(*args, **kwargs): pass" ] }, { @@ -201,22 +196,30 @@ "metadata": {}, "outputs": [ { - "name": "stderr", - "output_type": "stream", - "text": [ - "Using pad_token, but it is not set yet.\n" - ] + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "3040c20b4d87433bbdc4897d1e59b8e7", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Loading weights: 0%| | 0/148 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" }, { - "name": "stdout", + "name": "stderr", "output_type": "stream", "text": [ - "Loaded pretrained model gpt2-small into HookedTransformer\n" + "Warning: You are sending unauthenticated requests to the HF Hub. Please set a HF_TOKEN to enable higher rate limits and faster downloads.\n" ] } ], "source": [ - "model = HookedTransformer.from_pretrained(\"gpt2-small\")" + "model = TransformerBridge.boot_transformers(\"gpt2\")\n", + "model.enable_compatibility_mode()" ] }, { @@ -237,7 +240,7 @@ " [ 6035, 15686],\n", " [15686, 6035],\n", " [ 5780, 14235],\n", - " [14235, 5780]], device='cuda:0')\n" + " [14235, 5780]], device='mps:0')\n" ] } ], @@ -357,7 +360,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "d1e093d4bf1e47488095305a6b8b90d6", + "model_id": "5a9681ae4564413486b12c0767555d73", "version_major": 2, "version_minor": 0 }, @@ -375,9 +378,9 @@ "
\n", "\n", "