diff --git a/demos/Exploratory_Analysis_Demo.ipynb b/demos/Exploratory_Analysis_Demo.ipynb
index 48caba76c..c2c86cea8 100644
--- a/demos/Exploratory_Analysis_Demo.ipynb
+++ b/demos/Exploratory_Analysis_Demo.ipynb
@@ -62,7 +62,7 @@
},
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -86,8 +86,8 @@
"if not IN_COLAB:\n",
" from IPython import get_ipython\n",
" ip = get_ipython()\n",
- " if 'autoreload' not in ip.extension_manager.loaded:\n",
- " ip.extension_manager.load_extension('autoreload')\n",
+ " if not ip.extension_manager.loaded:\n",
+ " ip.extension_manager.load('autoreload')\n",
" %autoreload 2\n"
]
},
@@ -100,7 +100,7 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -118,7 +118,8 @@
"from jaxtyping import Float\n",
"\n",
"import transformer_lens.utils as utils\n",
- "from transformer_lens import ActivationCache, HookedTransformer"
+ "from transformer_lens import ActivationCache\n",
+ "from transformer_lens.model_bridge import TransformerBridge"
]
},
{
@@ -137,17 +138,9 @@
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Disabled automatic differentiation\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"torch.set_grad_enabled(False)\n",
"print(\"Disabled automatic differentiation\")"
@@ -169,7 +162,7 @@
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -245,33 +238,18 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "The first step is to load in our model, GPT-2 Small, a 12 layer and 80M parameter transformer with `HookedTransformer.from_pretrained`. The various flags are simplifications that preserve the model's output but simplify its internals."
+ "The first step is to load in our model, GPT-2 Small, a 12 layer and 80M parameter transformer with `TransformerBridge.boot_transformers`. The various flags are simplifications that preserve the model's output but simplify its internals."
]
},
{
"cell_type": "code",
- "execution_count": 5,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "Using pad_token, but it is not set yet.\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Loaded pretrained model gpt2-small into HookedTransformer\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"# NBVAL_IGNORE_OUTPUT\n",
- "model = HookedTransformer.from_pretrained(\n",
- " \"gpt2-small\",\n",
+ "model = TransformerBridge.boot_transformers(\"gpt2\")\n",
+ "model.enable_compatibility_mode(\n",
" center_unembed=True,\n",
" center_writing_weights=True,\n",
" fold_ln=True,\n",
@@ -298,62 +276,9 @@
},
{
"cell_type": "code",
- "execution_count": 6,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Tokenized prompt: ['<|endoftext|>', 'After', ' John', ' and', ' Mary', ' went', ' to', ' the', ' store', ',', ' John', ' gave', ' a', ' bottle', ' of', ' milk', ' to']\n",
- "Tokenized answer: [' Mary']\n"
- ]
- },
- {
- "data": {
- "text/html": [
- "
Performance on answer token:\n",
- "Rank: 0 Logit: 18.09 Prob: 70.07% Token: | Mary|\n",
- "
\n"
- ],
- "text/plain": [
- "Performance on answer token:\n",
- "\u001b[1mRank: \u001b[0m\u001b[1;36m0\u001b[0m\u001b[1m Logit: \u001b[0m\u001b[1;36m18.09\u001b[0m\u001b[1m Prob: \u001b[0m\u001b[1;36m70.07\u001b[0m\u001b[1m% Token: | Mary|\u001b[0m\n"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Top 0th token. Logit: 18.09 Prob: 70.07% Token: | Mary|\n",
- "Top 1th token. Logit: 15.38 Prob: 4.67% Token: | the|\n",
- "Top 2th token. Logit: 15.35 Prob: 4.54% Token: | John|\n",
- "Top 3th token. Logit: 15.25 Prob: 4.11% Token: | them|\n",
- "Top 4th token. Logit: 14.84 Prob: 2.73% Token: | his|\n",
- "Top 5th token. Logit: 14.06 Prob: 1.24% Token: | her|\n",
- "Top 6th token. Logit: 13.54 Prob: 0.74% Token: | a|\n",
- "Top 7th token. Logit: 13.52 Prob: 0.73% Token: | their|\n",
- "Top 8th token. Logit: 13.13 Prob: 0.49% Token: | Jesus|\n",
- "Top 9th token. Logit: 12.97 Prob: 0.42% Token: | him|\n"
- ]
- },
- {
- "data": {
- "text/html": [
- "Ranks of the answer tokens: [(' Mary', 0)]\n",
- "\n"
- ],
- "text/plain": [
- "\u001b[1mRanks of the answer tokens:\u001b[0m \u001b[1m[\u001b[0m\u001b[1m(\u001b[0m\u001b[32m' Mary'\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m)\u001b[0m\u001b[1m]\u001b[0m\n"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"example_prompt = \"After John and Mary went to the store, John gave a bottle of milk to\"\n",
"example_answer = \" Mary\"\n",
@@ -372,25 +297,16 @@
"\n",
"We want models that can take in arbitrary text, but models need to have a fixed vocabulary. So the solution is to define a vocabulary of **tokens** and to deterministically break up arbitrary text into tokens. Tokens are, essentially, subwords, and are determined by finding the most frequent substrings - this means that tokens vary a lot in length and frequency! \n",
"\n",
- "Tokens are a *massive* headache and are one of the most annoying things about reverse engineering language models... Different names will be different numbers of tokens, different prompts will have the relevant tokens at different positions, different prompts will have different total numbers of tokens, etc. Language models often devote significant amounts of parameters in early layers to convert inputs from tokens to a more sensible internal format (and do the reverse in later layers). You really, really want to avoid needing to think about tokenization wherever possible when doing exploratory analysis (though, of course, it's relevant later when trying to flesh out your analysis and make it rigorous!). HookedTransformer comes with several helper methods to deal with tokens: `to_tokens, to_string, to_str_tokens, to_single_token, get_token_position`\n",
+ "Tokens are a *massive* headache and are one of the most annoying things about reverse engineering language models... Different names will be different numbers of tokens, different prompts will have the relevant tokens at different positions, different prompts will have different total numbers of tokens, etc. Language models often devote significant amounts of parameters in early layers to convert inputs from tokens to a more sensible internal format (and do the reverse in later layers). You really, really want to avoid needing to think about tokenization wherever possible when doing exploratory analysis (though, of course, it's relevant later when trying to flesh out your analysis and make it rigorous!). TransformerBridge comes with several helper methods to deal with tokens: `to_tokens, to_string, to_str_tokens, to_single_token, get_token_position`\n",
"\n",
"**Exercise:** I recommend using `model.to_str_tokens` to explore how the model tokenizes different strings. In particular, try adding or removing spaces at the start, or changing capitalization - these change tokenization!"
]
},
{
"cell_type": "code",
- "execution_count": 7,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "['When John and Mary went to the shops, John gave the bag to', 'When John and Mary went to the shops, Mary gave the bag to', 'When Tom and James went to the park, James gave the ball to', 'When Tom and James went to the park, Tom gave the ball to', 'When Dan and Sid went to the shops, Sid gave an apple to', 'When Dan and Sid went to the shops, Dan gave an apple to', 'After Martin and Amy went to the park, Amy gave a drink to', 'After Martin and Amy went to the park, Martin gave a drink to']\n",
- "[(' Mary', ' John'), (' John', ' Mary'), (' Tom', ' James'), (' James', ' Tom'), (' Dan', ' Sid'), (' Sid', ' Dan'), (' Martin', ' Amy'), (' Amy', ' Martin')]\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"prompt_format = [\n",
" \"When John and Mary went to the shops,{} gave the bag to\",\n",
@@ -440,32 +356,9 @@
},
{
"cell_type": "code",
- "execution_count": 8,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Prompt length: 15\n",
- "Prompt as tokens: ['<|endoftext|>', 'When', ' John', ' and', ' Mary', ' went', ' to', ' the', ' shops', ',', ' John', ' gave', ' the', ' bag', ' to']\n",
- "Prompt length: 15\n",
- "Prompt as tokens: ['<|endoftext|>', 'When', ' John', ' and', ' Mary', ' went', ' to', ' the', ' shops', ',', ' Mary', ' gave', ' the', ' bag', ' to']\n",
- "Prompt length: 15\n",
- "Prompt as tokens: ['<|endoftext|>', 'When', ' Tom', ' and', ' James', ' went', ' to', ' the', ' park', ',', ' James', ' gave', ' the', ' ball', ' to']\n",
- "Prompt length: 15\n",
- "Prompt as tokens: ['<|endoftext|>', 'When', ' Tom', ' and', ' James', ' went', ' to', ' the', ' park', ',', ' Tom', ' gave', ' the', ' ball', ' to']\n",
- "Prompt length: 15\n",
- "Prompt as tokens: ['<|endoftext|>', 'When', ' Dan', ' and', ' Sid', ' went', ' to', ' the', ' shops', ',', ' Sid', ' gave', ' an', ' apple', ' to']\n",
- "Prompt length: 15\n",
- "Prompt as tokens: ['<|endoftext|>', 'When', ' Dan', ' and', ' Sid', ' went', ' to', ' the', ' shops', ',', ' Dan', ' gave', ' an', ' apple', ' to']\n",
- "Prompt length: 15\n",
- "Prompt as tokens: ['<|endoftext|>', 'After', ' Martin', ' and', ' Amy', ' went', ' to', ' the', ' park', ',', ' Amy', ' gave', ' a', ' drink', ' to']\n",
- "Prompt length: 15\n",
- "Prompt as tokens: ['<|endoftext|>', 'After', ' Martin', ' and', ' Amy', ' went', ' to', ' the', ' park', ',', ' Martin', ' gave', ' a', ' drink', ' to']\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"for prompt in prompts:\n",
" str_tokens = model.to_str_tokens(prompt)\n",
@@ -482,7 +375,7 @@
},
{
"cell_type": "code",
- "execution_count": 9,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -501,18 +394,9 @@
},
{
"cell_type": "code",
- "execution_count": 10,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Per prompt logit difference: tensor([3.3370, 3.2020, 2.7090, 3.7970, 1.7200, 5.2810, 2.6010, 5.7670])\n",
- "Average logit difference: 3.552\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"def logits_to_ave_logit_diff(logits, answer_tokens, per_prompt=False):\n",
" # Only the final logits are relevant for the answer\n",
@@ -638,25 +522,22 @@
},
{
"cell_type": "code",
- "execution_count": 11,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Answer residual directions shape: torch.Size([8, 2, 768])\n",
- "Logit difference directions shape: torch.Size([8, 768])\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
- "answer_residual_directions = model.tokens_to_residual_directions(answer_tokens)\n",
+ "# TransformerBridge doesn't have tokens_to_residual_directions yet,\n",
+ "# so we implement it inline using model.unembed.W_U\n",
+ "W_U = model.unembed.W_U # [d_model, d_vocab]\n",
+ "answer_residual_directions = W_U[:, answer_tokens]\n",
+ "answer_residual_directions = einops.rearrange(\n",
+ " answer_residual_directions, \"d_model batch correct_incorrect -> batch correct_incorrect d_model\"\n",
+ ")\n",
"print(\"Answer residual directions shape:\", answer_residual_directions.shape)\n",
"logit_diff_directions = (\n",
" answer_residual_directions[:, 0] - answer_residual_directions[:, 1]\n",
")\n",
- "print(\"Logit difference directions shape:\", logit_diff_directions.shape)"
+ "print(\"Logit difference directions shape:\", logit_diff_directions.shape)\n"
]
},
{
@@ -682,19 +563,9 @@
},
{
"cell_type": "code",
- "execution_count": 12,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Final residual stream shape: torch.Size([8, 15, 768])\n",
- "Calculated average logit diff: 3.552\n",
- "Original logit difference: 3.552\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"# cache syntax - resid_post is the residual stream at the end of the layer, -1 gets the final layer. The general syntax is [activation_name, layer_index, sub_layer_type].\n",
"final_residual_stream = cache[\"resid_post\", -1]\n",
@@ -731,7 +602,7 @@
},
{
"cell_type": "code",
- "execution_count": 13,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -769,966 +640,9 @@
},
{
"cell_type": "code",
- "execution_count": 14,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "application/vnd.plotly.v1+json": {
- "config": {
- "plotlyServerURL": "https://plot.ly"
- },
- "data": [
- {
- "hovertemplate": "%{hovertext}
x=%{x}
y=%{y}",
- "hovertext": [
- "0_pre",
- "0_mid",
- "1_pre",
- "1_mid",
- "2_pre",
- "2_mid",
- "3_pre",
- "3_mid",
- "4_pre",
- "4_mid",
- "5_pre",
- "5_mid",
- "6_pre",
- "6_mid",
- "7_pre",
- "7_mid",
- "8_pre",
- "8_mid",
- "9_pre",
- "9_mid",
- "10_pre",
- "10_mid",
- "11_pre",
- "11_mid",
- "final_post"
- ],
- "legendgroup": "",
- "line": {
- "color": "#636efa",
- "dash": "solid"
- },
- "marker": {
- "symbol": "circle"
- },
- "mode": "lines",
- "name": "",
- "orientation": "v",
- "showlegend": false,
- "type": "scatter",
- "x": [
- 0,
- 0.5,
- 1,
- 1.5,
- 2,
- 2.5,
- 3,
- 3.5,
- 4,
- 4.5,
- 5,
- 5.5,
- 6,
- 6.5,
- 7,
- 7.5,
- 8,
- 8.5,
- 9,
- 9.5,
- 10,
- 10.5,
- 11,
- 11.5,
- 12
- ],
- "xaxis": "x",
- "y": [
- 1.2937933206558228e-05,
- -0.006643360480666161,
- -0.007525032386183739,
- -0.009075596928596497,
- -0.008736769668757915,
- -0.008685456588864326,
- -0.006480347365140915,
- -0.007939882576465607,
- -0.009661720134317875,
- -0.015095856040716171,
- -0.01419061329215765,
- -0.019930001348257065,
- -0.00912435818463564,
- -0.027298055589199066,
- -0.02985510788857937,
- 0.2497255504131317,
- 0.250558078289032,
- 0.45005205273628235,
- 0.45996904373168945,
- 5.02545166015625,
- 5.142900466918945,
- 4.730565071105957,
- 4.887058258056641,
- 3.445383071899414,
- 3.5518720149993896
- ],
- "yaxis": "y"
- }
- ],
- "layout": {
- "legend": {
- "tracegroupgap": 0
- },
- "template": {
- "data": {
- "bar": [
- {
- "error_x": {
- "color": "#2a3f5f"
- },
- "error_y": {
- "color": "#2a3f5f"
- },
- "marker": {
- "line": {
- "color": "#E5ECF6",
- "width": 0.5
- },
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "bar"
- }
- ],
- "barpolar": [
- {
- "marker": {
- "line": {
- "color": "#E5ECF6",
- "width": 0.5
- },
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "barpolar"
- }
- ],
- "carpet": [
- {
- "aaxis": {
- "endlinecolor": "#2a3f5f",
- "gridcolor": "white",
- "linecolor": "white",
- "minorgridcolor": "white",
- "startlinecolor": "#2a3f5f"
- },
- "baxis": {
- "endlinecolor": "#2a3f5f",
- "gridcolor": "white",
- "linecolor": "white",
- "minorgridcolor": "white",
- "startlinecolor": "#2a3f5f"
- },
- "type": "carpet"
- }
- ],
- "choropleth": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "choropleth"
- }
- ],
- "contour": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "contour"
- }
- ],
- "contourcarpet": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "contourcarpet"
- }
- ],
- "heatmap": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "heatmap"
- }
- ],
- "heatmapgl": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "heatmapgl"
- }
- ],
- "histogram": [
- {
- "marker": {
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "histogram"
- }
- ],
- "histogram2d": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "histogram2d"
- }
- ],
- "histogram2dcontour": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "histogram2dcontour"
- }
- ],
- "mesh3d": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "mesh3d"
- }
- ],
- "parcoords": [
- {
- "line": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "parcoords"
- }
- ],
- "pie": [
- {
- "automargin": true,
- "type": "pie"
- }
- ],
- "scatter": [
- {
- "fillpattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- },
- "type": "scatter"
- }
- ],
- "scatter3d": [
- {
- "line": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatter3d"
- }
- ],
- "scattercarpet": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattercarpet"
- }
- ],
- "scattergeo": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattergeo"
- }
- ],
- "scattergl": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattergl"
- }
- ],
- "scattermapbox": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattermapbox"
- }
- ],
- "scatterpolar": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterpolar"
- }
- ],
- "scatterpolargl": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterpolargl"
- }
- ],
- "scatterternary": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterternary"
- }
- ],
- "surface": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "surface"
- }
- ],
- "table": [
- {
- "cells": {
- "fill": {
- "color": "#EBF0F8"
- },
- "line": {
- "color": "white"
- }
- },
- "header": {
- "fill": {
- "color": "#C8D4E3"
- },
- "line": {
- "color": "white"
- }
- },
- "type": "table"
- }
- ]
- },
- "layout": {
- "annotationdefaults": {
- "arrowcolor": "#2a3f5f",
- "arrowhead": 0,
- "arrowwidth": 1
- },
- "autotypenumbers": "strict",
- "coloraxis": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "colorscale": {
- "diverging": [
- [
- 0,
- "#8e0152"
- ],
- [
- 0.1,
- "#c51b7d"
- ],
- [
- 0.2,
- "#de77ae"
- ],
- [
- 0.3,
- "#f1b6da"
- ],
- [
- 0.4,
- "#fde0ef"
- ],
- [
- 0.5,
- "#f7f7f7"
- ],
- [
- 0.6,
- "#e6f5d0"
- ],
- [
- 0.7,
- "#b8e186"
- ],
- [
- 0.8,
- "#7fbc41"
- ],
- [
- 0.9,
- "#4d9221"
- ],
- [
- 1,
- "#276419"
- ]
- ],
- "sequential": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "sequentialminus": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ]
- },
- "colorway": [
- "#636efa",
- "#EF553B",
- "#00cc96",
- "#ab63fa",
- "#FFA15A",
- "#19d3f3",
- "#FF6692",
- "#B6E880",
- "#FF97FF",
- "#FECB52"
- ],
- "font": {
- "color": "#2a3f5f"
- },
- "geo": {
- "bgcolor": "white",
- "lakecolor": "white",
- "landcolor": "#E5ECF6",
- "showlakes": true,
- "showland": true,
- "subunitcolor": "white"
- },
- "hoverlabel": {
- "align": "left"
- },
- "hovermode": "closest",
- "mapbox": {
- "style": "light"
- },
- "paper_bgcolor": "white",
- "plot_bgcolor": "#E5ECF6",
- "polar": {
- "angularaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "bgcolor": "#E5ECF6",
- "radialaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- }
- },
- "scene": {
- "xaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- },
- "yaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- },
- "zaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- }
- },
- "shapedefaults": {
- "line": {
- "color": "#2a3f5f"
- }
- },
- "ternary": {
- "aaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "baxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "bgcolor": "#E5ECF6",
- "caxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- }
- },
- "title": {
- "x": 0.05
- },
- "xaxis": {
- "automargin": true,
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": "",
- "title": {
- "standoff": 15
- },
- "zerolinecolor": "white",
- "zerolinewidth": 2
- },
- "yaxis": {
- "automargin": true,
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": "",
- "title": {
- "standoff": 15
- },
- "zerolinecolor": "white",
- "zerolinewidth": 2
- }
- }
- },
- "title": {
- "text": "Logit Difference From Accumulate Residual Stream"
- },
- "xaxis": {
- "anchor": "y",
- "domain": [
- 0,
- 1
- ],
- "title": {
- "text": "x"
- }
- },
- "yaxis": {
- "anchor": "x",
- "domain": [
- 0,
- 1
- ],
- "title": {
- "text": "y"
- }
- }
- }
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"accumulated_residual, labels = cache.accumulated_resid(\n",
" layer=-1, incl_mid=True, pos_slice=-1, return_labels=True\n",
@@ -1762,969 +676,9 @@
},
{
"cell_type": "code",
- "execution_count": 15,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "application/vnd.plotly.v1+json": {
- "config": {
- "plotlyServerURL": "https://plot.ly"
- },
- "data": [
- {
- "hovertemplate": "%{hovertext}
x=%{x}
y=%{y}",
- "hovertext": [
- "embed",
- "pos_embed",
- "0_attn_out",
- "0_mlp_out",
- "1_attn_out",
- "1_mlp_out",
- "2_attn_out",
- "2_mlp_out",
- "3_attn_out",
- "3_mlp_out",
- "4_attn_out",
- "4_mlp_out",
- "5_attn_out",
- "5_mlp_out",
- "6_attn_out",
- "6_mlp_out",
- "7_attn_out",
- "7_mlp_out",
- "8_attn_out",
- "8_mlp_out",
- "9_attn_out",
- "9_mlp_out",
- "10_attn_out",
- "10_mlp_out",
- "11_attn_out",
- "11_mlp_out"
- ],
- "legendgroup": "",
- "line": {
- "color": "#636efa",
- "dash": "solid"
- },
- "marker": {
- "symbol": "circle"
- },
- "mode": "lines",
- "name": "",
- "orientation": "v",
- "showlegend": false,
- "type": "scatter",
- "x": [
- 0,
- 1,
- 2,
- 3,
- 4,
- 5,
- 6,
- 7,
- 8,
- 9,
- 10,
- 11,
- 12,
- 13,
- 14,
- 15,
- 16,
- 17,
- 18,
- 19,
- 20,
- 21,
- 22,
- 23,
- 24,
- 25
- ],
- "xaxis": "x",
- "y": [
- -0.00028366726473905146,
- 0.00029660604195669293,
- -0.0066563040018081665,
- -0.0008816685294732451,
- -0.0015505650080740452,
- 0.00033882574643939734,
- 5.131529178470373e-05,
- 0.0022051138803362846,
- -0.0014595506945624948,
- -0.0017218313878402114,
- -0.005434143822640181,
- 0.0009052485693246126,
- -0.0057394010946154594,
- 0.010805649682879448,
- -0.018173698335886,
- -0.002557049971073866,
- 0.27958065271377563,
- 0.0008325176313519478,
- 0.19949400424957275,
- 0.00991708692163229,
- 4.565483093261719,
- 0.11744903028011322,
- -0.4123360514640808,
- 0.15649384260177612,
- -1.4416757822036743,
- 0.10648896545171738
- ],
- "yaxis": "y"
- }
- ],
- "layout": {
- "legend": {
- "tracegroupgap": 0
- },
- "template": {
- "data": {
- "bar": [
- {
- "error_x": {
- "color": "#2a3f5f"
- },
- "error_y": {
- "color": "#2a3f5f"
- },
- "marker": {
- "line": {
- "color": "#E5ECF6",
- "width": 0.5
- },
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "bar"
- }
- ],
- "barpolar": [
- {
- "marker": {
- "line": {
- "color": "#E5ECF6",
- "width": 0.5
- },
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "barpolar"
- }
- ],
- "carpet": [
- {
- "aaxis": {
- "endlinecolor": "#2a3f5f",
- "gridcolor": "white",
- "linecolor": "white",
- "minorgridcolor": "white",
- "startlinecolor": "#2a3f5f"
- },
- "baxis": {
- "endlinecolor": "#2a3f5f",
- "gridcolor": "white",
- "linecolor": "white",
- "minorgridcolor": "white",
- "startlinecolor": "#2a3f5f"
- },
- "type": "carpet"
- }
- ],
- "choropleth": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "choropleth"
- }
- ],
- "contour": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "contour"
- }
- ],
- "contourcarpet": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "contourcarpet"
- }
- ],
- "heatmap": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "heatmap"
- }
- ],
- "heatmapgl": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "heatmapgl"
- }
- ],
- "histogram": [
- {
- "marker": {
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "histogram"
- }
- ],
- "histogram2d": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "histogram2d"
- }
- ],
- "histogram2dcontour": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "histogram2dcontour"
- }
- ],
- "mesh3d": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "mesh3d"
- }
- ],
- "parcoords": [
- {
- "line": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "parcoords"
- }
- ],
- "pie": [
- {
- "automargin": true,
- "type": "pie"
- }
- ],
- "scatter": [
- {
- "fillpattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- },
- "type": "scatter"
- }
- ],
- "scatter3d": [
- {
- "line": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatter3d"
- }
- ],
- "scattercarpet": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattercarpet"
- }
- ],
- "scattergeo": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattergeo"
- }
- ],
- "scattergl": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattergl"
- }
- ],
- "scattermapbox": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattermapbox"
- }
- ],
- "scatterpolar": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterpolar"
- }
- ],
- "scatterpolargl": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterpolargl"
- }
- ],
- "scatterternary": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterternary"
- }
- ],
- "surface": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "surface"
- }
- ],
- "table": [
- {
- "cells": {
- "fill": {
- "color": "#EBF0F8"
- },
- "line": {
- "color": "white"
- }
- },
- "header": {
- "fill": {
- "color": "#C8D4E3"
- },
- "line": {
- "color": "white"
- }
- },
- "type": "table"
- }
- ]
- },
- "layout": {
- "annotationdefaults": {
- "arrowcolor": "#2a3f5f",
- "arrowhead": 0,
- "arrowwidth": 1
- },
- "autotypenumbers": "strict",
- "coloraxis": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "colorscale": {
- "diverging": [
- [
- 0,
- "#8e0152"
- ],
- [
- 0.1,
- "#c51b7d"
- ],
- [
- 0.2,
- "#de77ae"
- ],
- [
- 0.3,
- "#f1b6da"
- ],
- [
- 0.4,
- "#fde0ef"
- ],
- [
- 0.5,
- "#f7f7f7"
- ],
- [
- 0.6,
- "#e6f5d0"
- ],
- [
- 0.7,
- "#b8e186"
- ],
- [
- 0.8,
- "#7fbc41"
- ],
- [
- 0.9,
- "#4d9221"
- ],
- [
- 1,
- "#276419"
- ]
- ],
- "sequential": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "sequentialminus": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ]
- },
- "colorway": [
- "#636efa",
- "#EF553B",
- "#00cc96",
- "#ab63fa",
- "#FFA15A",
- "#19d3f3",
- "#FF6692",
- "#B6E880",
- "#FF97FF",
- "#FECB52"
- ],
- "font": {
- "color": "#2a3f5f"
- },
- "geo": {
- "bgcolor": "white",
- "lakecolor": "white",
- "landcolor": "#E5ECF6",
- "showlakes": true,
- "showland": true,
- "subunitcolor": "white"
- },
- "hoverlabel": {
- "align": "left"
- },
- "hovermode": "closest",
- "mapbox": {
- "style": "light"
- },
- "paper_bgcolor": "white",
- "plot_bgcolor": "#E5ECF6",
- "polar": {
- "angularaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "bgcolor": "#E5ECF6",
- "radialaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- }
- },
- "scene": {
- "xaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- },
- "yaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- },
- "zaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- }
- },
- "shapedefaults": {
- "line": {
- "color": "#2a3f5f"
- }
- },
- "ternary": {
- "aaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "baxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "bgcolor": "#E5ECF6",
- "caxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- }
- },
- "title": {
- "x": 0.05
- },
- "xaxis": {
- "automargin": true,
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": "",
- "title": {
- "standoff": 15
- },
- "zerolinecolor": "white",
- "zerolinewidth": 2
- },
- "yaxis": {
- "automargin": true,
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": "",
- "title": {
- "standoff": 15
- },
- "zerolinecolor": "white",
- "zerolinewidth": 2
- }
- }
- },
- "title": {
- "text": "Logit Difference From Each Layer"
- },
- "xaxis": {
- "anchor": "y",
- "domain": [
- 0,
- 1
- ],
- "title": {
- "text": "x"
- }
- },
- "yaxis": {
- "anchor": "x",
- "domain": [
- 0,
- 1
- ],
- "title": {
- "text": "y"
- }
- }
- }
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"per_layer_residual, labels = cache.decompose_resid(\n",
" layer=-1, pos_slice=-1, return_labels=True\n",
@@ -2757,1102 +711,9 @@
},
{
"cell_type": "code",
- "execution_count": 16,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Tried to stack head results when they weren't cached. Computing head results now\n"
- ]
- },
- {
- "data": {
- "application/vnd.plotly.v1+json": {
- "config": {
- "plotlyServerURL": "https://plot.ly"
- },
- "data": [
- {
- "coloraxis": "coloraxis",
- "hovertemplate": "Head: %{x}
Layer: %{y}
color: %{z}",
- "name": "0",
- "type": "heatmap",
- "xaxis": "x",
- "yaxis": "y",
- "z": [
- [
- -0.0020563392899930477,
- -0.0005101899732835591,
- 0.0004685786843765527,
- 0.00012512074317783117,
- -0.0006028738571330905,
- -0.0002429460291750729,
- -0.0023189077619463205,
- -0.002758360467851162,
- 0.000564602785743773,
- 0.0009697531932033598,
- -0.0002504526637494564,
- 4.737317794933915e-06
- ],
- [
- -0.0010070882271975279,
- 0.00039470894262194633,
- -0.00154874159488827,
- 0.0014034928753972054,
- -0.0012653048615902662,
- -0.0011358022456988692,
- -0.00281596090644598,
- -0.0029645217582583427,
- 0.0029190476052463055,
- 0.0025743592996150255,
- 0.00036239007022231817,
- 0.0017548729665577412
- ],
- [
- 0.0005569400964304805,
- -0.001126631861552596,
- -0.0017353934235870838,
- -0.0014514457434415817,
- -0.00028735760133713484,
- 0.0017211002996191382,
- 0.0026658899150788784,
- 0.00311466702260077,
- 0.0005667927907779813,
- -0.003666515462100506,
- -0.0018847601022571325,
- 7.039372576400638e-06
- ],
- [
- -0.0007264417363330722,
- 0.00011364505917299539,
- 0.0014301587361842394,
- 0.0007490540738217533,
- 0.0020184689201414585,
- 0.0007436950691044331,
- -0.00046178390039131045,
- -0.0039057559333741665,
- 0.0011406694538891315,
- -4.022853681817651e-05,
- -0.0013293239753693342,
- -0.0017636751290410757
- ],
- [
- -0.0028280913829803467,
- 0.00033634810824878514,
- -0.0014248639345169067,
- -0.003777273464947939,
- 0.0015998880844563246,
- 0.0002989505883306265,
- -0.000804675742983818,
- 0.002038792008534074,
- -0.0015593919670209289,
- -0.0006436670082621276,
- 0.0011168173514306545,
- -0.00035012533771805465
- ],
- [
- 0.0011338205076754093,
- 0.0011259170714765787,
- -0.002516670385375619,
- -0.0014790185960009694,
- 0.0003878737334161997,
- -6.408110493794084e-05,
- -0.0005096744280308485,
- -0.0008840755908749998,
- 0.0006398351397365332,
- -0.0010097370250150561,
- -0.006759158335626125,
- 0.0033667823299765587
- ],
- [
- -0.01514742337167263,
- -0.0021350777242332697,
- 0.002593174111098051,
- -0.00042678468162193894,
- -0.005558924749493599,
- 0.0026658528950065374,
- 0.006411008536815643,
- -0.003826778382062912,
- -0.0003843410813715309,
- -0.0016430341638624668,
- -0.0013344454346224666,
- -9.20506427064538e-05
- ],
- [
- -9.476230479776859e-05,
- -0.0057889921590685844,
- -0.0006383581785485148,
- 0.13493388891220093,
- -0.001768707763403654,
- -0.018917907029390335,
- 0.003873429261147976,
- -0.0021450775675475597,
- -0.010327338241040707,
- 0.18325845897197723,
- -0.0007747983909212053,
- -0.00104526337236166
- ],
- [
- -0.003833949100226164,
- -0.0008046097937040031,
- -0.012673400342464447,
- 0.00804573018103838,
- 0.003604492638260126,
- -0.009398287162184715,
- -0.08272082358598709,
- 0.003555194940418005,
- -0.018404025584459305,
- 0.0017587244510650635,
- 0.2896133363246918,
- 0.022854052484035492
- ],
- [
- 0.08595258742570877,
- -0.0006932877004146576,
- 0.06817055493593216,
- 0.013111240230500698,
- -0.021098043769598007,
- 0.05112447217106819,
- 1.3844914436340332,
- 0.045836858451366425,
- -0.03830280900001526,
- 2.985445976257324,
- 0.0019662054255604744,
- -0.008030137047171593
- ],
- [
- 0.5608693957328796,
- 0.17083050310611725,
- -0.03361757844686508,
- 0.05821544677019119,
- -0.0024530249647796154,
- 0.0018771197646856308,
- 0.28827205300331116,
- -1.8986485004425049,
- -0.0015286931302398443,
- -0.035129792988300323,
- 0.4802178740501404,
- -0.0009115453576669097
- ],
- [
- 0.016075748950242996,
- -0.03986122086644173,
- -0.3879126012325287,
- 0.011123123578727245,
- -0.005477819126099348,
- -0.0025129620917141438,
- -0.08056175708770752,
- 0.007518616039305925,
- 0.0430111438035965,
- -0.040082238614559174,
- -0.9702364802360535,
- 0.011862239800393581
- ]
- ]
- }
- ],
- "layout": {
- "coloraxis": {
- "cmid": 0,
- "colorscale": [
- [
- 0,
- "rgb(103,0,31)"
- ],
- [
- 0.1,
- "rgb(178,24,43)"
- ],
- [
- 0.2,
- "rgb(214,96,77)"
- ],
- [
- 0.3,
- "rgb(244,165,130)"
- ],
- [
- 0.4,
- "rgb(253,219,199)"
- ],
- [
- 0.5,
- "rgb(247,247,247)"
- ],
- [
- 0.6,
- "rgb(209,229,240)"
- ],
- [
- 0.7,
- "rgb(146,197,222)"
- ],
- [
- 0.8,
- "rgb(67,147,195)"
- ],
- [
- 0.9,
- "rgb(33,102,172)"
- ],
- [
- 1,
- "rgb(5,48,97)"
- ]
- ]
- },
- "template": {
- "data": {
- "bar": [
- {
- "error_x": {
- "color": "#2a3f5f"
- },
- "error_y": {
- "color": "#2a3f5f"
- },
- "marker": {
- "line": {
- "color": "#E5ECF6",
- "width": 0.5
- },
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "bar"
- }
- ],
- "barpolar": [
- {
- "marker": {
- "line": {
- "color": "#E5ECF6",
- "width": 0.5
- },
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "barpolar"
- }
- ],
- "carpet": [
- {
- "aaxis": {
- "endlinecolor": "#2a3f5f",
- "gridcolor": "white",
- "linecolor": "white",
- "minorgridcolor": "white",
- "startlinecolor": "#2a3f5f"
- },
- "baxis": {
- "endlinecolor": "#2a3f5f",
- "gridcolor": "white",
- "linecolor": "white",
- "minorgridcolor": "white",
- "startlinecolor": "#2a3f5f"
- },
- "type": "carpet"
- }
- ],
- "choropleth": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "choropleth"
- }
- ],
- "contour": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "contour"
- }
- ],
- "contourcarpet": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "contourcarpet"
- }
- ],
- "heatmap": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "heatmap"
- }
- ],
- "heatmapgl": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "heatmapgl"
- }
- ],
- "histogram": [
- {
- "marker": {
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "histogram"
- }
- ],
- "histogram2d": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "histogram2d"
- }
- ],
- "histogram2dcontour": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "histogram2dcontour"
- }
- ],
- "mesh3d": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "mesh3d"
- }
- ],
- "parcoords": [
- {
- "line": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "parcoords"
- }
- ],
- "pie": [
- {
- "automargin": true,
- "type": "pie"
- }
- ],
- "scatter": [
- {
- "fillpattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- },
- "type": "scatter"
- }
- ],
- "scatter3d": [
- {
- "line": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatter3d"
- }
- ],
- "scattercarpet": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattercarpet"
- }
- ],
- "scattergeo": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattergeo"
- }
- ],
- "scattergl": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattergl"
- }
- ],
- "scattermapbox": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattermapbox"
- }
- ],
- "scatterpolar": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterpolar"
- }
- ],
- "scatterpolargl": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterpolargl"
- }
- ],
- "scatterternary": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterternary"
- }
- ],
- "surface": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "surface"
- }
- ],
- "table": [
- {
- "cells": {
- "fill": {
- "color": "#EBF0F8"
- },
- "line": {
- "color": "white"
- }
- },
- "header": {
- "fill": {
- "color": "#C8D4E3"
- },
- "line": {
- "color": "white"
- }
- },
- "type": "table"
- }
- ]
- },
- "layout": {
- "annotationdefaults": {
- "arrowcolor": "#2a3f5f",
- "arrowhead": 0,
- "arrowwidth": 1
- },
- "autotypenumbers": "strict",
- "coloraxis": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "colorscale": {
- "diverging": [
- [
- 0,
- "#8e0152"
- ],
- [
- 0.1,
- "#c51b7d"
- ],
- [
- 0.2,
- "#de77ae"
- ],
- [
- 0.3,
- "#f1b6da"
- ],
- [
- 0.4,
- "#fde0ef"
- ],
- [
- 0.5,
- "#f7f7f7"
- ],
- [
- 0.6,
- "#e6f5d0"
- ],
- [
- 0.7,
- "#b8e186"
- ],
- [
- 0.8,
- "#7fbc41"
- ],
- [
- 0.9,
- "#4d9221"
- ],
- [
- 1,
- "#276419"
- ]
- ],
- "sequential": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "sequentialminus": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ]
- },
- "colorway": [
- "#636efa",
- "#EF553B",
- "#00cc96",
- "#ab63fa",
- "#FFA15A",
- "#19d3f3",
- "#FF6692",
- "#B6E880",
- "#FF97FF",
- "#FECB52"
- ],
- "font": {
- "color": "#2a3f5f"
- },
- "geo": {
- "bgcolor": "white",
- "lakecolor": "white",
- "landcolor": "#E5ECF6",
- "showlakes": true,
- "showland": true,
- "subunitcolor": "white"
- },
- "hoverlabel": {
- "align": "left"
- },
- "hovermode": "closest",
- "mapbox": {
- "style": "light"
- },
- "paper_bgcolor": "white",
- "plot_bgcolor": "#E5ECF6",
- "polar": {
- "angularaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "bgcolor": "#E5ECF6",
- "radialaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- }
- },
- "scene": {
- "xaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- },
- "yaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- },
- "zaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- }
- },
- "shapedefaults": {
- "line": {
- "color": "#2a3f5f"
- }
- },
- "ternary": {
- "aaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "baxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "bgcolor": "#E5ECF6",
- "caxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- }
- },
- "title": {
- "x": 0.05
- },
- "xaxis": {
- "automargin": true,
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": "",
- "title": {
- "standoff": 15
- },
- "zerolinecolor": "white",
- "zerolinewidth": 2
- },
- "yaxis": {
- "automargin": true,
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": "",
- "title": {
- "standoff": 15
- },
- "zerolinecolor": "white",
- "zerolinewidth": 2
- }
- }
- },
- "title": {
- "text": "Logit Difference From Each Head"
- },
- "xaxis": {
- "anchor": "y",
- "constrain": "domain",
- "domain": [
- 0,
- 1
- ],
- "scaleanchor": "y",
- "title": {
- "text": "Head"
- }
- },
- "yaxis": {
- "anchor": "x",
- "autorange": "reversed",
- "constrain": "domain",
- "domain": [
- 0,
- 1
- ],
- "title": {
- "text": "Layer"
- }
- }
- }
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"per_head_residual, labels = cache.stack_head_results(\n",
" layer=-1, pos_slice=-1, return_labels=True\n",
@@ -3893,7 +754,7 @@
},
{
"cell_type": "code",
- "execution_count": 17,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -3908,6 +769,11 @@
" if isinstance(heads, int):\n",
" heads = [heads]\n",
"\n",
+ " # Handle empty head list\n",
+ " if len(heads) == 0:\n",
+ " title_html = f\"{title}
\"\n",
+ " return f\"{title_html}
No heads in this group
\"\n",
+ "\n",
" # Create the plotting data\n",
" labels: List[str] = []\n",
" patterns: List[Float[torch.Tensor, \"dest_pos src_pos\"]] = []\n",
@@ -3954,39 +820,9 @@
},
{
"cell_type": "code",
- "execution_count": 18,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "Top 3 Positive Logit Attribution Heads
\n",
- "
Top 3 Negative Logit Attribution Heads
\n",
- "
"
- ],
- "text/plain": [
- ""
- ]
- },
- "execution_count": 18,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
"top_k = 3\n",
"\n",
@@ -4098,18 +934,9 @@
},
{
"cell_type": "code",
- "execution_count": 19,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Corrupted Average Logit Diff -3.55\n",
- "Clean Average Logit Diff 3.55\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"corrupted_prompts = []\n",
"for i in range(0, len(prompts), 2):\n",
@@ -4126,27 +953,9 @@
},
{
"cell_type": "code",
- "execution_count": 20,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "['<|endoftext|>When John and Mary went to the shops, Mary gave the bag to',\n",
- " '<|endoftext|>When John and Mary went to the shops, John gave the bag to',\n",
- " '<|endoftext|>When Tom and James went to the park, Tom gave the ball to',\n",
- " '<|endoftext|>When Tom and James went to the park, James gave the ball to',\n",
- " '<|endoftext|>When Dan and Sid went to the shops, Dan gave an apple to',\n",
- " '<|endoftext|>When Dan and Sid went to the shops, Sid gave an apple to',\n",
- " '<|endoftext|>After Martin and Amy went to the park, Martin gave a drink to',\n",
- " '<|endoftext|>After Martin and Amy went to the park, Amy gave a drink to']"
- ]
- },
- "execution_count": 20,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
"model.to_string(corrupted_tokens)"
]
@@ -4163,7 +972,7 @@
},
{
"cell_type": "code",
- "execution_count": 21,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -4173,7 +982,9 @@
" pos,\n",
" clean_cache,\n",
"):\n",
- " corrupted_residual_component[:, pos, :] = clean_cache[hook.name][:, pos, :]\n",
+ " clean_value = clean_cache[hook.name][:, pos, :].clone()\n",
+ " corrupted_residual_component = corrupted_residual_component.clone()\n",
+ " corrupted_residual_component[:, pos : pos + 1, :] = clean_value.unsqueeze(1)\n",
" return corrupted_residual_component\n",
"\n",
"\n",
@@ -4217,1148 +1028,9 @@
},
{
"cell_type": "code",
- "execution_count": 22,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "application/vnd.plotly.v1+json": {
- "config": {
- "plotlyServerURL": "https://plot.ly"
- },
- "data": [
- {
- "coloraxis": "coloraxis",
- "hovertemplate": "Position: %{x}
Layer: %{y}
color: %{z}",
- "name": "0",
- "type": "heatmap",
- "x": [
- "<|endoftext|>_0",
- "When_1",
- " John_2",
- " and_3",
- " Mary_4",
- " went_5",
- " to_6",
- " the_7",
- " shops_8",
- ",_9",
- " John_10",
- " gave_11",
- " the_12",
- " bag_13",
- " to_14"
- ],
- "xaxis": "x",
- "yaxis": "y",
- "z": [
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 1,
- 0,
- 0,
- 0,
- 0
- ],
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 1.000650405883789,
- -0.0002469856117386371,
- 9.76665523921838e-06,
- -0.00036458822432905436,
- -4.8967522161547095e-05
- ],
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 1.001051902770996,
- -2.7621845219982788e-05,
- -1.9768245692830533e-05,
- -0.0004596704675350338,
- -0.0005947590689174831
- ],
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 1.0002663135528564,
- 0.0008680911851115525,
- 0.0005157867562957108,
- -0.0009929431835189462,
- -0.0008658089209347963
- ],
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0.994907796382904,
- 0.005429857410490513,
- 0.0016050540143623948,
- -0.0006193603039719164,
- -0.0016324409516528249
- ],
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0.9675672054290771,
- 0.03134213387966156,
- 0.0028418952133506536,
- -0.0012302964460104704,
- -0.000985861523076892
- ],
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0.967520534992218,
- 0.03100077249109745,
- 0.0017823305679485202,
- -0.00048668819363228977,
- -0.0006467136554419994
- ],
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0.9228319525718689,
- 0.05134531855583191,
- 0.004728672094643116,
- 0.0009345446596853435,
- 0.017046840861439705
- ],
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0.6565483808517456,
- 0.02385685034096241,
- 0.002357019344344735,
- -1.7183941963594407e-05,
- 0.3186916410923004
- ],
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0.027302566915750504,
- 0.03142499923706055,
- 0.0018202561186626554,
- 0.0007990868762135506,
- 0.9383866190910339
- ],
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- -0.026841485872864723,
- 0.02098155952990055,
- 0.0012512058019638062,
- 0.00032317222212441266,
- 1.0048279762268066
- ],
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- -0.005687985569238663,
- 0.014263377524912357,
- 0.00048709093243815005,
- -8.977938705356792e-05,
- 0.9914212226867676
- ]
- ]
- }
- ],
- "layout": {
- "coloraxis": {
- "cmid": 0,
- "colorscale": [
- [
- 0,
- "rgb(103,0,31)"
- ],
- [
- 0.1,
- "rgb(178,24,43)"
- ],
- [
- 0.2,
- "rgb(214,96,77)"
- ],
- [
- 0.3,
- "rgb(244,165,130)"
- ],
- [
- 0.4,
- "rgb(253,219,199)"
- ],
- [
- 0.5,
- "rgb(247,247,247)"
- ],
- [
- 0.6,
- "rgb(209,229,240)"
- ],
- [
- 0.7,
- "rgb(146,197,222)"
- ],
- [
- 0.8,
- "rgb(67,147,195)"
- ],
- [
- 0.9,
- "rgb(33,102,172)"
- ],
- [
- 1,
- "rgb(5,48,97)"
- ]
- ]
- },
- "template": {
- "data": {
- "bar": [
- {
- "error_x": {
- "color": "#2a3f5f"
- },
- "error_y": {
- "color": "#2a3f5f"
- },
- "marker": {
- "line": {
- "color": "#E5ECF6",
- "width": 0.5
- },
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "bar"
- }
- ],
- "barpolar": [
- {
- "marker": {
- "line": {
- "color": "#E5ECF6",
- "width": 0.5
- },
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "barpolar"
- }
- ],
- "carpet": [
- {
- "aaxis": {
- "endlinecolor": "#2a3f5f",
- "gridcolor": "white",
- "linecolor": "white",
- "minorgridcolor": "white",
- "startlinecolor": "#2a3f5f"
- },
- "baxis": {
- "endlinecolor": "#2a3f5f",
- "gridcolor": "white",
- "linecolor": "white",
- "minorgridcolor": "white",
- "startlinecolor": "#2a3f5f"
- },
- "type": "carpet"
- }
- ],
- "choropleth": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "choropleth"
- }
- ],
- "contour": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "contour"
- }
- ],
- "contourcarpet": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "contourcarpet"
- }
- ],
- "heatmap": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "heatmap"
- }
- ],
- "heatmapgl": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "heatmapgl"
- }
- ],
- "histogram": [
- {
- "marker": {
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "histogram"
- }
- ],
- "histogram2d": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "histogram2d"
- }
- ],
- "histogram2dcontour": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "histogram2dcontour"
- }
- ],
- "mesh3d": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "mesh3d"
- }
- ],
- "parcoords": [
- {
- "line": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "parcoords"
- }
- ],
- "pie": [
- {
- "automargin": true,
- "type": "pie"
- }
- ],
- "scatter": [
- {
- "fillpattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- },
- "type": "scatter"
- }
- ],
- "scatter3d": [
- {
- "line": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatter3d"
- }
- ],
- "scattercarpet": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattercarpet"
- }
- ],
- "scattergeo": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattergeo"
- }
- ],
- "scattergl": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattergl"
- }
- ],
- "scattermapbox": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattermapbox"
- }
- ],
- "scatterpolar": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterpolar"
- }
- ],
- "scatterpolargl": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterpolargl"
- }
- ],
- "scatterternary": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterternary"
- }
- ],
- "surface": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "surface"
- }
- ],
- "table": [
- {
- "cells": {
- "fill": {
- "color": "#EBF0F8"
- },
- "line": {
- "color": "white"
- }
- },
- "header": {
- "fill": {
- "color": "#C8D4E3"
- },
- "line": {
- "color": "white"
- }
- },
- "type": "table"
- }
- ]
- },
- "layout": {
- "annotationdefaults": {
- "arrowcolor": "#2a3f5f",
- "arrowhead": 0,
- "arrowwidth": 1
- },
- "autotypenumbers": "strict",
- "coloraxis": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "colorscale": {
- "diverging": [
- [
- 0,
- "#8e0152"
- ],
- [
- 0.1,
- "#c51b7d"
- ],
- [
- 0.2,
- "#de77ae"
- ],
- [
- 0.3,
- "#f1b6da"
- ],
- [
- 0.4,
- "#fde0ef"
- ],
- [
- 0.5,
- "#f7f7f7"
- ],
- [
- 0.6,
- "#e6f5d0"
- ],
- [
- 0.7,
- "#b8e186"
- ],
- [
- 0.8,
- "#7fbc41"
- ],
- [
- 0.9,
- "#4d9221"
- ],
- [
- 1,
- "#276419"
- ]
- ],
- "sequential": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "sequentialminus": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ]
- },
- "colorway": [
- "#636efa",
- "#EF553B",
- "#00cc96",
- "#ab63fa",
- "#FFA15A",
- "#19d3f3",
- "#FF6692",
- "#B6E880",
- "#FF97FF",
- "#FECB52"
- ],
- "font": {
- "color": "#2a3f5f"
- },
- "geo": {
- "bgcolor": "white",
- "lakecolor": "white",
- "landcolor": "#E5ECF6",
- "showlakes": true,
- "showland": true,
- "subunitcolor": "white"
- },
- "hoverlabel": {
- "align": "left"
- },
- "hovermode": "closest",
- "mapbox": {
- "style": "light"
- },
- "paper_bgcolor": "white",
- "plot_bgcolor": "#E5ECF6",
- "polar": {
- "angularaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "bgcolor": "#E5ECF6",
- "radialaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- }
- },
- "scene": {
- "xaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- },
- "yaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- },
- "zaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- }
- },
- "shapedefaults": {
- "line": {
- "color": "#2a3f5f"
- }
- },
- "ternary": {
- "aaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "baxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "bgcolor": "#E5ECF6",
- "caxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- }
- },
- "title": {
- "x": 0.05
- },
- "xaxis": {
- "automargin": true,
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": "",
- "title": {
- "standoff": 15
- },
- "zerolinecolor": "white",
- "zerolinewidth": 2
- },
- "yaxis": {
- "automargin": true,
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": "",
- "title": {
- "standoff": 15
- },
- "zerolinecolor": "white",
- "zerolinewidth": 2
- }
- }
- },
- "title": {
- "text": "Logit Difference From Patched Residual Stream"
- },
- "xaxis": {
- "anchor": "y",
- "constrain": "domain",
- "domain": [
- 0,
- 1
- ],
- "scaleanchor": "y",
- "title": {
- "text": "Position"
- }
- },
- "yaxis": {
- "anchor": "x",
- "autorange": "reversed",
- "constrain": "domain",
- "domain": [
- 0,
- 1
- ],
- "title": {
- "text": "Layer"
- }
- }
- }
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"prompt_position_labels = [\n",
" f\"{tok}_{i}\" for i, tok in enumerate(model.to_str_tokens(tokens[0]))\n",
@@ -5387,7 +1059,7 @@
},
{
"cell_type": "code",
- "execution_count": 23,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -5434,1148 +1106,9 @@
},
{
"cell_type": "code",
- "execution_count": 24,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "application/vnd.plotly.v1+json": {
- "config": {
- "plotlyServerURL": "https://plot.ly"
- },
- "data": [
- {
- "coloraxis": "coloraxis",
- "hovertemplate": "Position: %{x}
Layer: %{y}
color: %{z}",
- "name": "0",
- "type": "heatmap",
- "x": [
- "<|endoftext|>_0",
- "When_1",
- " John_2",
- " and_3",
- " Mary_4",
- " went_5",
- " to_6",
- " the_7",
- " shops_8",
- ",_9",
- " John_10",
- " gave_11",
- " the_12",
- " bag_13",
- " to_14"
- ],
- "xaxis": "x",
- "yaxis": "y",
- "z": [
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0.035456884652376175,
- -0.0002469856117386371,
- 9.76665523921838e-06,
- -0.00036458822432905436,
- -4.8967522161547095e-05
- ],
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- -0.0029848709236830473,
- 7.950929284561425e-05,
- 2.0842242520302534e-05,
- 8.088535105343908e-05,
- -0.0005967392353340983
- ],
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- -0.0019131568260490894,
- 0.0006668510613963008,
- 0.00039482791908085346,
- -0.0007051457650959492,
- -0.00027282864903099835
- ],
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0.1546323299407959,
- 0.0038019807543605566,
- 0.0005171628436073661,
- -0.00011964991426793858,
- -0.0005599213181994855
- ],
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- -0.005406397394835949,
- 0.019581740722060204,
- 0.001007509301416576,
- -0.0002424211270408705,
- 0.0007936497568152845
- ],
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0.3520970046520233,
- 0.0010525835677981377,
- 0.00022436455765273422,
- 0.00013367898645810783,
- 8.172441448550671e-05
- ],
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0.11986024677753448,
- 0.021243548020720482,
- 0.002727783052250743,
- 0.0013409851817414165,
- 0.01797366514801979
- ],
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0.013310473412275314,
- 0.011509180068969727,
- 0.00037542887730523944,
- -4.094611358596012e-05,
- 0.29760244488716125
- ],
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- -0.0015009435592219234,
- 0.017351653426885605,
- 0.0005848917062394321,
- 0.0010122752282768488,
- 0.5697318911552429
- ],
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- -0.00012901381705887616,
- 0.00630143890157342,
- 0.00014156615361571312,
- 0.00031229801243171096,
- 0.27152299880981445
- ],
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- -0.0009373303619213402,
- 8.669164526509121e-05,
- 0.00033243544748984277,
- 9.73309283835988e-07,
- -0.1929796040058136
- ],
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- -0.40617984533309937
- ]
- ]
- }
- ],
- "layout": {
- "coloraxis": {
- "cmid": 0,
- "colorscale": [
- [
- 0,
- "rgb(103,0,31)"
- ],
- [
- 0.1,
- "rgb(178,24,43)"
- ],
- [
- 0.2,
- "rgb(214,96,77)"
- ],
- [
- 0.3,
- "rgb(244,165,130)"
- ],
- [
- 0.4,
- "rgb(253,219,199)"
- ],
- [
- 0.5,
- "rgb(247,247,247)"
- ],
- [
- 0.6,
- "rgb(209,229,240)"
- ],
- [
- 0.7,
- "rgb(146,197,222)"
- ],
- [
- 0.8,
- "rgb(67,147,195)"
- ],
- [
- 0.9,
- "rgb(33,102,172)"
- ],
- [
- 1,
- "rgb(5,48,97)"
- ]
- ]
- },
- "template": {
- "data": {
- "bar": [
- {
- "error_x": {
- "color": "#2a3f5f"
- },
- "error_y": {
- "color": "#2a3f5f"
- },
- "marker": {
- "line": {
- "color": "#E5ECF6",
- "width": 0.5
- },
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "bar"
- }
- ],
- "barpolar": [
- {
- "marker": {
- "line": {
- "color": "#E5ECF6",
- "width": 0.5
- },
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "barpolar"
- }
- ],
- "carpet": [
- {
- "aaxis": {
- "endlinecolor": "#2a3f5f",
- "gridcolor": "white",
- "linecolor": "white",
- "minorgridcolor": "white",
- "startlinecolor": "#2a3f5f"
- },
- "baxis": {
- "endlinecolor": "#2a3f5f",
- "gridcolor": "white",
- "linecolor": "white",
- "minorgridcolor": "white",
- "startlinecolor": "#2a3f5f"
- },
- "type": "carpet"
- }
- ],
- "choropleth": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "choropleth"
- }
- ],
- "contour": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "contour"
- }
- ],
- "contourcarpet": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "contourcarpet"
- }
- ],
- "heatmap": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "heatmap"
- }
- ],
- "heatmapgl": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "heatmapgl"
- }
- ],
- "histogram": [
- {
- "marker": {
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "histogram"
- }
- ],
- "histogram2d": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "histogram2d"
- }
- ],
- "histogram2dcontour": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "histogram2dcontour"
- }
- ],
- "mesh3d": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "mesh3d"
- }
- ],
- "parcoords": [
- {
- "line": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "parcoords"
- }
- ],
- "pie": [
- {
- "automargin": true,
- "type": "pie"
- }
- ],
- "scatter": [
- {
- "fillpattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- },
- "type": "scatter"
- }
- ],
- "scatter3d": [
- {
- "line": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatter3d"
- }
- ],
- "scattercarpet": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattercarpet"
- }
- ],
- "scattergeo": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattergeo"
- }
- ],
- "scattergl": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattergl"
- }
- ],
- "scattermapbox": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattermapbox"
- }
- ],
- "scatterpolar": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterpolar"
- }
- ],
- "scatterpolargl": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterpolargl"
- }
- ],
- "scatterternary": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterternary"
- }
- ],
- "surface": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "surface"
- }
- ],
- "table": [
- {
- "cells": {
- "fill": {
- "color": "#EBF0F8"
- },
- "line": {
- "color": "white"
- }
- },
- "header": {
- "fill": {
- "color": "#C8D4E3"
- },
- "line": {
- "color": "white"
- }
- },
- "type": "table"
- }
- ]
- },
- "layout": {
- "annotationdefaults": {
- "arrowcolor": "#2a3f5f",
- "arrowhead": 0,
- "arrowwidth": 1
- },
- "autotypenumbers": "strict",
- "coloraxis": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "colorscale": {
- "diverging": [
- [
- 0,
- "#8e0152"
- ],
- [
- 0.1,
- "#c51b7d"
- ],
- [
- 0.2,
- "#de77ae"
- ],
- [
- 0.3,
- "#f1b6da"
- ],
- [
- 0.4,
- "#fde0ef"
- ],
- [
- 0.5,
- "#f7f7f7"
- ],
- [
- 0.6,
- "#e6f5d0"
- ],
- [
- 0.7,
- "#b8e186"
- ],
- [
- 0.8,
- "#7fbc41"
- ],
- [
- 0.9,
- "#4d9221"
- ],
- [
- 1,
- "#276419"
- ]
- ],
- "sequential": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "sequentialminus": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ]
- },
- "colorway": [
- "#636efa",
- "#EF553B",
- "#00cc96",
- "#ab63fa",
- "#FFA15A",
- "#19d3f3",
- "#FF6692",
- "#B6E880",
- "#FF97FF",
- "#FECB52"
- ],
- "font": {
- "color": "#2a3f5f"
- },
- "geo": {
- "bgcolor": "white",
- "lakecolor": "white",
- "landcolor": "#E5ECF6",
- "showlakes": true,
- "showland": true,
- "subunitcolor": "white"
- },
- "hoverlabel": {
- "align": "left"
- },
- "hovermode": "closest",
- "mapbox": {
- "style": "light"
- },
- "paper_bgcolor": "white",
- "plot_bgcolor": "#E5ECF6",
- "polar": {
- "angularaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "bgcolor": "#E5ECF6",
- "radialaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- }
- },
- "scene": {
- "xaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- },
- "yaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- },
- "zaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- }
- },
- "shapedefaults": {
- "line": {
- "color": "#2a3f5f"
- }
- },
- "ternary": {
- "aaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "baxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "bgcolor": "#E5ECF6",
- "caxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- }
- },
- "title": {
- "x": 0.05
- },
- "xaxis": {
- "automargin": true,
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": "",
- "title": {
- "standoff": 15
- },
- "zerolinecolor": "white",
- "zerolinewidth": 2
- },
- "yaxis": {
- "automargin": true,
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": "",
- "title": {
- "standoff": 15
- },
- "zerolinecolor": "white",
- "zerolinewidth": 2
- }
- }
- },
- "title": {
- "text": "Logit Difference From Patched Attention Layer"
- },
- "xaxis": {
- "anchor": "y",
- "constrain": "domain",
- "domain": [
- 0,
- 1
- ],
- "scaleanchor": "y",
- "title": {
- "text": "Position"
- }
- },
- "yaxis": {
- "anchor": "x",
- "autorange": "reversed",
- "constrain": "domain",
- "domain": [
- 0,
- 1
- ],
- "title": {
- "text": "Layer"
- }
- }
- }
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"imshow(\n",
" patched_attn_diff,\n",
@@ -6606,1148 +1139,9 @@
},
{
"cell_type": "code",
- "execution_count": 25,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "application/vnd.plotly.v1+json": {
- "config": {
- "plotlyServerURL": "https://plot.ly"
- },
- "data": [
- {
- "coloraxis": "coloraxis",
- "hovertemplate": "Position: %{x}
Layer: %{y}
color: %{z}",
- "name": "0",
- "type": "heatmap",
- "x": [
- "<|endoftext|>_0",
- "When_1",
- " John_2",
- " and_3",
- " Mary_4",
- " went_5",
- " to_6",
- " the_7",
- " shops_8",
- ",_9",
- " John_10",
- " gave_11",
- " the_12",
- " bag_13",
- " to_14"
- ],
- "xaxis": "x",
- "yaxis": "y",
- "z": [
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0.8507890701293945,
- -0.00027843358111567795,
- -7.293107046280056e-05,
- -0.00047373308916576207,
- 4.0039929444901645e-05
- ],
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0.008863994851708412,
- 0.000222149450564757,
- 0.00014938619278836995,
- -4.853121208725497e-05,
- 0.000304041663184762
- ],
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0.013550343923270702,
- 5.86334899708163e-05,
- -0.0003296833310741931,
- -0.0006382559076882899,
- 0.0007730424986220896
- ],
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0.0019468198297545314,
- 0.0004995090421289206,
- 0.00017318192112725228,
- 0.00016871812113095075,
- 0.00040764876757748425
- ],
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- -0.019787074998021126,
- 0.004128609783947468,
- -4.86990247736685e-05,
- -0.00017019486404024065,
- 0.0007914346642792225
- ],
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0.09652391821146011,
- -0.0018826150335371494,
- -0.0004844730719923973,
- 0.0007094081956893206,
- -0.00018335132335778326
- ],
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- -0.015900013968348503,
- -0.0008501688134856522,
- 0.00012337534280959517,
- 2.7521158699528314e-05,
- -0.007238299585878849
- ],
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0.010360540822148323,
- 0.0031509376130998135,
- 0.0005309234256856143,
- 0.0002361114020459354,
- 0.008496351540088654
- ],
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- -0.012533102184534073,
- 2.201692586822901e-05,
- -0.00035374757135286927,
- 8.615465048933402e-05,
- -0.021631328389048576
- ],
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- -0.00033465056912973523,
- 0.0008094912045635283,
- 1.6244195649051107e-05,
- 0.00012924875773023814,
- 0.03162466362118721
- ],
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0.0013599144294857979,
- -0.00019499746849760413,
- -9.934466652339324e-05,
- -0.00014217027637641877,
- 0.028764141723513603
- ],
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0.02044912613928318
- ]
- ]
- }
- ],
- "layout": {
- "coloraxis": {
- "cmid": 0,
- "colorscale": [
- [
- 0,
- "rgb(103,0,31)"
- ],
- [
- 0.1,
- "rgb(178,24,43)"
- ],
- [
- 0.2,
- "rgb(214,96,77)"
- ],
- [
- 0.3,
- "rgb(244,165,130)"
- ],
- [
- 0.4,
- "rgb(253,219,199)"
- ],
- [
- 0.5,
- "rgb(247,247,247)"
- ],
- [
- 0.6,
- "rgb(209,229,240)"
- ],
- [
- 0.7,
- "rgb(146,197,222)"
- ],
- [
- 0.8,
- "rgb(67,147,195)"
- ],
- [
- 0.9,
- "rgb(33,102,172)"
- ],
- [
- 1,
- "rgb(5,48,97)"
- ]
- ]
- },
- "template": {
- "data": {
- "bar": [
- {
- "error_x": {
- "color": "#2a3f5f"
- },
- "error_y": {
- "color": "#2a3f5f"
- },
- "marker": {
- "line": {
- "color": "#E5ECF6",
- "width": 0.5
- },
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "bar"
- }
- ],
- "barpolar": [
- {
- "marker": {
- "line": {
- "color": "#E5ECF6",
- "width": 0.5
- },
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "barpolar"
- }
- ],
- "carpet": [
- {
- "aaxis": {
- "endlinecolor": "#2a3f5f",
- "gridcolor": "white",
- "linecolor": "white",
- "minorgridcolor": "white",
- "startlinecolor": "#2a3f5f"
- },
- "baxis": {
- "endlinecolor": "#2a3f5f",
- "gridcolor": "white",
- "linecolor": "white",
- "minorgridcolor": "white",
- "startlinecolor": "#2a3f5f"
- },
- "type": "carpet"
- }
- ],
- "choropleth": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "choropleth"
- }
- ],
- "contour": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "contour"
- }
- ],
- "contourcarpet": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "contourcarpet"
- }
- ],
- "heatmap": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "heatmap"
- }
- ],
- "heatmapgl": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "heatmapgl"
- }
- ],
- "histogram": [
- {
- "marker": {
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "histogram"
- }
- ],
- "histogram2d": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "histogram2d"
- }
- ],
- "histogram2dcontour": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "histogram2dcontour"
- }
- ],
- "mesh3d": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "mesh3d"
- }
- ],
- "parcoords": [
- {
- "line": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "parcoords"
- }
- ],
- "pie": [
- {
- "automargin": true,
- "type": "pie"
- }
- ],
- "scatter": [
- {
- "fillpattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- },
- "type": "scatter"
- }
- ],
- "scatter3d": [
- {
- "line": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatter3d"
- }
- ],
- "scattercarpet": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattercarpet"
- }
- ],
- "scattergeo": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattergeo"
- }
- ],
- "scattergl": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattergl"
- }
- ],
- "scattermapbox": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattermapbox"
- }
- ],
- "scatterpolar": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterpolar"
- }
- ],
- "scatterpolargl": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterpolargl"
- }
- ],
- "scatterternary": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterternary"
- }
- ],
- "surface": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "surface"
- }
- ],
- "table": [
- {
- "cells": {
- "fill": {
- "color": "#EBF0F8"
- },
- "line": {
- "color": "white"
- }
- },
- "header": {
- "fill": {
- "color": "#C8D4E3"
- },
- "line": {
- "color": "white"
- }
- },
- "type": "table"
- }
- ]
- },
- "layout": {
- "annotationdefaults": {
- "arrowcolor": "#2a3f5f",
- "arrowhead": 0,
- "arrowwidth": 1
- },
- "autotypenumbers": "strict",
- "coloraxis": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "colorscale": {
- "diverging": [
- [
- 0,
- "#8e0152"
- ],
- [
- 0.1,
- "#c51b7d"
- ],
- [
- 0.2,
- "#de77ae"
- ],
- [
- 0.3,
- "#f1b6da"
- ],
- [
- 0.4,
- "#fde0ef"
- ],
- [
- 0.5,
- "#f7f7f7"
- ],
- [
- 0.6,
- "#e6f5d0"
- ],
- [
- 0.7,
- "#b8e186"
- ],
- [
- 0.8,
- "#7fbc41"
- ],
- [
- 0.9,
- "#4d9221"
- ],
- [
- 1,
- "#276419"
- ]
- ],
- "sequential": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "sequentialminus": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ]
- },
- "colorway": [
- "#636efa",
- "#EF553B",
- "#00cc96",
- "#ab63fa",
- "#FFA15A",
- "#19d3f3",
- "#FF6692",
- "#B6E880",
- "#FF97FF",
- "#FECB52"
- ],
- "font": {
- "color": "#2a3f5f"
- },
- "geo": {
- "bgcolor": "white",
- "lakecolor": "white",
- "landcolor": "#E5ECF6",
- "showlakes": true,
- "showland": true,
- "subunitcolor": "white"
- },
- "hoverlabel": {
- "align": "left"
- },
- "hovermode": "closest",
- "mapbox": {
- "style": "light"
- },
- "paper_bgcolor": "white",
- "plot_bgcolor": "#E5ECF6",
- "polar": {
- "angularaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "bgcolor": "#E5ECF6",
- "radialaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- }
- },
- "scene": {
- "xaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- },
- "yaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- },
- "zaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- }
- },
- "shapedefaults": {
- "line": {
- "color": "#2a3f5f"
- }
- },
- "ternary": {
- "aaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "baxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "bgcolor": "#E5ECF6",
- "caxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- }
- },
- "title": {
- "x": 0.05
- },
- "xaxis": {
- "automargin": true,
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": "",
- "title": {
- "standoff": 15
- },
- "zerolinecolor": "white",
- "zerolinewidth": 2
- },
- "yaxis": {
- "automargin": true,
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": "",
- "title": {
- "standoff": 15
- },
- "zerolinecolor": "white",
- "zerolinewidth": 2
- }
- }
- },
- "title": {
- "text": "Logit Difference From Patched MLP Layer"
- },
- "xaxis": {
- "anchor": "y",
- "constrain": "domain",
- "domain": [
- 0,
- 1
- ],
- "scaleanchor": "y",
- "title": {
- "text": "Position"
- }
- },
- "yaxis": {
- "anchor": "x",
- "autorange": "reversed",
- "constrain": "domain",
- "domain": [
- 0,
- 1
- ],
- "title": {
- "text": "Layer"
- }
- }
- }
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"imshow(\n",
" patched_mlp_diff,\n",
@@ -7770,7 +1164,7 @@
},
{
"cell_type": "code",
- "execution_count": 26,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -7780,9 +1174,11 @@
" head_index,\n",
" clean_cache,\n",
"):\n",
- " corrupted_head_vector[:, :, head_index, :] = clean_cache[hook.name][\n",
+ " clean_value = clean_cache[hook.name][\n",
" :, :, head_index, :\n",
- " ]\n",
+ " ].clone()\n",
+ " corrupted_head_vector = corrupted_head_vector.clone()\n",
+ " corrupted_head_vector[:, :, head_index : head_index + 1, :] = clean_value.unsqueeze(2)\n",
" return corrupted_head_vector\n",
"\n",
"\n",
@@ -7813,1095 +1209,9 @@
},
{
"cell_type": "code",
- "execution_count": 27,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "application/vnd.plotly.v1+json": {
- "config": {
- "plotlyServerURL": "https://plot.ly"
- },
- "data": [
- {
- "coloraxis": "coloraxis",
- "hovertemplate": "Head: %{x}
Layer: %{y}
color: %{z}",
- "name": "0",
- "type": "heatmap",
- "xaxis": "x",
- "yaxis": "y",
- "z": [
- [
- 0.0009487751522101462,
- 0.016124747693538666,
- 0.0018548924708738923,
- 0.0034389030188322067,
- -0.00982347596436739,
- 0.011058605276048183,
- -0.004063969012349844,
- -0.0015792781487107277,
- -0.0012082795146852732,
- 0.003828897839412093,
- -0.004256919026374817,
- -0.0011422622483223677
- ],
- [
- -0.0010771177476271987,
- -0.00037898647133260965,
- 2.5171791548928013e-06,
- -0.00026067905128002167,
- -0.00014146546891424805,
- 0.0038321535103023052,
- -0.0004293300735298544,
- -0.00142992555629462,
- -0.0009228314156644046,
- 0.0006944393389858305,
- 0.00043302192352712154,
- -0.0035714071709662676
- ],
- [
- -0.0004967569257132709,
- 0.0008057993836700916,
- 0.0005424688570201397,
- -0.0005309234256856143,
- -0.0007159864180721343,
- -0.0010389237431809306,
- -0.0009490771917626262,
- -8.649027586216107e-05,
- 0.0002766547549981624,
- 0.0021084228064864874,
- -0.0001975146442418918,
- -0.0016405630158260465
- ],
- [
- 0.1162627637386322,
- 0.0002507446042727679,
- -0.0014675153652206063,
- -0.00039680811460129917,
- 0.018962211906909943,
- -0.00018764731066767126,
- 0.011170871555805206,
- -0.0013301445869728923,
- -0.0007356539717875421,
- -0.00030253134900704026,
- -0.00014683544577565044,
- -0.00022228369198273867
- ],
- [
- -0.001650598249398172,
- 0.0002927311579696834,
- -0.00143563118763268,
- 0.03084198758006096,
- -0.007432155776768923,
- -0.00028236035723239183,
- 0.006017433945089579,
- -0.011007187888026237,
- -0.001266107545234263,
- 0.0014901700196787715,
- -0.0001800622121663764,
- 0.002944394713267684
- ],
- [
- -0.004211106337606907,
- 0.0029597999528050423,
- 0.002045023487880826,
- 0.0013397098518908024,
- -0.0012190865818411112,
- 0.34349915385246277,
- 0.0005632104002870619,
- -0.0001262281439267099,
- -0.00515326950699091,
- 0.016240738332271576,
- 0.01709030382335186,
- -0.004175194539129734
- ],
- [
- 0.039775289595127106,
- 0.015226684510707855,
- -0.0010229480685666203,
- 0.0008072761120274663,
- -0.004935584031045437,
- -0.002123525831848383,
- -0.014274083077907562,
- 0.0013746818294748664,
- 0.0014838266652077436,
- 0.1302703619003296,
- -0.00033616088330745697,
- 0.0012919505825266242
- ],
- [
- 0.00037177055492065847,
- 0.019514480605721474,
- 0.00022255218937061727,
- 0.124249167740345,
- -0.00040352059295400977,
- -0.007652895525097847,
- 0.0013010123511776328,
- -0.0011253133416175842,
- -0.007449474185705185,
- 0.19224143028259277,
- -0.003275118535384536,
- -0.0005017912480980158
- ],
- [
- -0.001007912098430097,
- 3.091096004936844e-05,
- -0.0008595998515374959,
- 0.012359987013041973,
- -0.0004041247011628002,
- -0.004328910261392593,
- 0.3185553252696991,
- 0.002330605871975422,
- 0.0021182901691645384,
- 0.0001405928487656638,
- 0.2779357433319092,
- 0.005738262087106705
- ],
- [
- 0.0058898297138512135,
- -0.0009689796715974808,
- 0.00912561360746622,
- 0.020675739273428917,
- -0.03700518235564232,
- 0.014263041317462921,
- -0.04828466475009918,
- 0.05834139883518219,
- 0.0006514795240946114,
- 0.26360899209976196,
- 0.0004918567719869316,
- -0.00261044898070395
- ],
- [
- 0.08374208211898804,
- 0.020676210522651672,
- -0.003743582172319293,
- 0.01085072010755539,
- -0.001096583902835846,
- 0.00047430366976186633,
- 0.04818058758974075,
- -0.4799128472805023,
- 0.00018429107149131596,
- 0.011861988343298435,
- 0.06088569387793541,
- 0.0008461413672193885
- ],
- [
- 0.005328264087438583,
- -0.011493473313748837,
- -0.11350836604833603,
- 0.006329597905278206,
- 0.00031669469899497926,
- -0.0011600167490541935,
- -0.022669579833745956,
- 0.004070379305630922,
- 0.0073160636238753796,
- -0.00834545586258173,
- -0.27817651629447937,
- 0.0036344374530017376
- ]
- ]
- }
- ],
- "layout": {
- "coloraxis": {
- "cmid": 0,
- "colorscale": [
- [
- 0,
- "rgb(103,0,31)"
- ],
- [
- 0.1,
- "rgb(178,24,43)"
- ],
- [
- 0.2,
- "rgb(214,96,77)"
- ],
- [
- 0.3,
- "rgb(244,165,130)"
- ],
- [
- 0.4,
- "rgb(253,219,199)"
- ],
- [
- 0.5,
- "rgb(247,247,247)"
- ],
- [
- 0.6,
- "rgb(209,229,240)"
- ],
- [
- 0.7,
- "rgb(146,197,222)"
- ],
- [
- 0.8,
- "rgb(67,147,195)"
- ],
- [
- 0.9,
- "rgb(33,102,172)"
- ],
- [
- 1,
- "rgb(5,48,97)"
- ]
- ]
- },
- "template": {
- "data": {
- "bar": [
- {
- "error_x": {
- "color": "#2a3f5f"
- },
- "error_y": {
- "color": "#2a3f5f"
- },
- "marker": {
- "line": {
- "color": "#E5ECF6",
- "width": 0.5
- },
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "bar"
- }
- ],
- "barpolar": [
- {
- "marker": {
- "line": {
- "color": "#E5ECF6",
- "width": 0.5
- },
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "barpolar"
- }
- ],
- "carpet": [
- {
- "aaxis": {
- "endlinecolor": "#2a3f5f",
- "gridcolor": "white",
- "linecolor": "white",
- "minorgridcolor": "white",
- "startlinecolor": "#2a3f5f"
- },
- "baxis": {
- "endlinecolor": "#2a3f5f",
- "gridcolor": "white",
- "linecolor": "white",
- "minorgridcolor": "white",
- "startlinecolor": "#2a3f5f"
- },
- "type": "carpet"
- }
- ],
- "choropleth": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "choropleth"
- }
- ],
- "contour": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "contour"
- }
- ],
- "contourcarpet": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "contourcarpet"
- }
- ],
- "heatmap": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "heatmap"
- }
- ],
- "heatmapgl": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "heatmapgl"
- }
- ],
- "histogram": [
- {
- "marker": {
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "histogram"
- }
- ],
- "histogram2d": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "histogram2d"
- }
- ],
- "histogram2dcontour": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "histogram2dcontour"
- }
- ],
- "mesh3d": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "mesh3d"
- }
- ],
- "parcoords": [
- {
- "line": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "parcoords"
- }
- ],
- "pie": [
- {
- "automargin": true,
- "type": "pie"
- }
- ],
- "scatter": [
- {
- "fillpattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- },
- "type": "scatter"
- }
- ],
- "scatter3d": [
- {
- "line": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatter3d"
- }
- ],
- "scattercarpet": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattercarpet"
- }
- ],
- "scattergeo": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattergeo"
- }
- ],
- "scattergl": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattergl"
- }
- ],
- "scattermapbox": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattermapbox"
- }
- ],
- "scatterpolar": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterpolar"
- }
- ],
- "scatterpolargl": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterpolargl"
- }
- ],
- "scatterternary": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterternary"
- }
- ],
- "surface": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "surface"
- }
- ],
- "table": [
- {
- "cells": {
- "fill": {
- "color": "#EBF0F8"
- },
- "line": {
- "color": "white"
- }
- },
- "header": {
- "fill": {
- "color": "#C8D4E3"
- },
- "line": {
- "color": "white"
- }
- },
- "type": "table"
- }
- ]
- },
- "layout": {
- "annotationdefaults": {
- "arrowcolor": "#2a3f5f",
- "arrowhead": 0,
- "arrowwidth": 1
- },
- "autotypenumbers": "strict",
- "coloraxis": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "colorscale": {
- "diverging": [
- [
- 0,
- "#8e0152"
- ],
- [
- 0.1,
- "#c51b7d"
- ],
- [
- 0.2,
- "#de77ae"
- ],
- [
- 0.3,
- "#f1b6da"
- ],
- [
- 0.4,
- "#fde0ef"
- ],
- [
- 0.5,
- "#f7f7f7"
- ],
- [
- 0.6,
- "#e6f5d0"
- ],
- [
- 0.7,
- "#b8e186"
- ],
- [
- 0.8,
- "#7fbc41"
- ],
- [
- 0.9,
- "#4d9221"
- ],
- [
- 1,
- "#276419"
- ]
- ],
- "sequential": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "sequentialminus": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ]
- },
- "colorway": [
- "#636efa",
- "#EF553B",
- "#00cc96",
- "#ab63fa",
- "#FFA15A",
- "#19d3f3",
- "#FF6692",
- "#B6E880",
- "#FF97FF",
- "#FECB52"
- ],
- "font": {
- "color": "#2a3f5f"
- },
- "geo": {
- "bgcolor": "white",
- "lakecolor": "white",
- "landcolor": "#E5ECF6",
- "showlakes": true,
- "showland": true,
- "subunitcolor": "white"
- },
- "hoverlabel": {
- "align": "left"
- },
- "hovermode": "closest",
- "mapbox": {
- "style": "light"
- },
- "paper_bgcolor": "white",
- "plot_bgcolor": "#E5ECF6",
- "polar": {
- "angularaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "bgcolor": "#E5ECF6",
- "radialaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- }
- },
- "scene": {
- "xaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- },
- "yaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- },
- "zaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- }
- },
- "shapedefaults": {
- "line": {
- "color": "#2a3f5f"
- }
- },
- "ternary": {
- "aaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "baxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "bgcolor": "#E5ECF6",
- "caxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- }
- },
- "title": {
- "x": 0.05
- },
- "xaxis": {
- "automargin": true,
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": "",
- "title": {
- "standoff": 15
- },
- "zerolinecolor": "white",
- "zerolinewidth": 2
- },
- "yaxis": {
- "automargin": true,
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": "",
- "title": {
- "standoff": 15
- },
- "zerolinecolor": "white",
- "zerolinewidth": 2
- }
- }
- },
- "title": {
- "text": "Logit Difference From Patched Head Output"
- },
- "xaxis": {
- "anchor": "y",
- "constrain": "domain",
- "domain": [
- 0,
- 1
- ],
- "scaleanchor": "y",
- "title": {
- "text": "Head"
- }
- },
- "yaxis": {
- "anchor": "x",
- "autorange": "reversed",
- "constrain": "domain",
- "domain": [
- 0,
- 1
- ],
- "title": {
- "text": "Layer"
- }
- }
- }
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"imshow(\n",
" patched_head_z_diff,\n",
@@ -8933,7 +1243,7 @@
},
{
"cell_type": "code",
- "execution_count": 28,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -8964,1095 +1274,9 @@
},
{
"cell_type": "code",
- "execution_count": 29,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "application/vnd.plotly.v1+json": {
- "config": {
- "plotlyServerURL": "https://plot.ly"
- },
- "data": [
- {
- "coloraxis": "coloraxis",
- "hovertemplate": "Head: %{x}
Layer: %{y}
color: %{z}",
- "name": "0",
- "type": "heatmap",
- "xaxis": "x",
- "yaxis": "y",
- "z": [
- [
- -0.00019892427371814847,
- 0.005339574534446001,
- 0.0006527548539452255,
- 0.003504416672512889,
- -0.00898387935012579,
- 0.0034814265090972185,
- -0.0008631910313852131,
- -3.406582254683599e-05,
- 0.0005166929331608117,
- 0.00044255363172851503,
- -0.0039068968035280704,
- -0.0001880836207419634
- ],
- [
- -0.0004399022145662457,
- -0.00044510437874123454,
- -6.73597096465528e-05,
- 7.242763240355998e-05,
- -3.6549441574607044e-05,
- -0.0019323208834975958,
- -0.0001572397886775434,
- 1.6143509128596634e-05,
- 0.00020593880617525429,
- 0.000336798548232764,
- 0.0003515324497129768,
- -0.0005669358652085066
- ],
- [
- 0.00021013410878367722,
- -0.0007199132232926786,
- 0.0004868560063187033,
- -0.0005974104860797524,
- -0.0005921411793678999,
- -0.0005443819100037217,
- -0.000227552984142676,
- -0.0004809825913980603,
- 0.00020570388005580753,
- 0.001183376181870699,
- -0.0003574058646336198,
- -0.0009104468626901507
- ],
- [
- 0.0010395278222858906,
- -0.00012042184971505776,
- -7.762980385450646e-05,
- -0.0007275318494066596,
- -0.001310007064603269,
- -0.0023108376190066338,
- 0.010987084358930588,
- -5.0712766096694395e-05,
- 0.00014314358122646809,
- 0.00015069512301124632,
- -7.957642083056271e-05,
- -2.0238119759596884e-05
- ],
- [
- -0.0005373673629947007,
- -0.0008137872209772468,
- -0.00013334336108528078,
- 0.030609702691435814,
- -0.007185807917267084,
- 0.000148916311445646,
- 0.0013340713921934366,
- -0.01142292469739914,
- -0.0005336419562809169,
- 0.0005126654868945479,
- 0.00037344868178479373,
- 0.0029547319281846285
- ],
- [
- 8.22278525447473e-06,
- 6.477540864580078e-06,
- 0.0015973682748153806,
- 0.00034015480196103454,
- -0.0012577504385262728,
- -5.450531898532063e-05,
- 0.0006331544718705118,
- -0.00027081489679403603,
- 7.427356467815116e-05,
- -0.006704355590045452,
- 0.003175975289195776,
- -0.0017300404142588377
- ],
- [
- 0.04863045737147331,
- 0.015314852818846703,
- -0.0004648726317100227,
- -0.00011676354915834963,
- -4.930314753437415e-05,
- -0.003952810075134039,
- -0.01737578585743904,
- -0.00015421917487401515,
- 0.0012194222072139382,
- -0.00018090127559844404,
- -0.00042647725786082447,
- 0.00012334177154116333
- ],
- [
- -2.956846401502844e-05,
- -0.0013855225406587124,
- -0.00012129446986364201,
- 0.1332160234451294,
- -0.00024490474606864154,
- -0.007315828464925289,
- 0.00033297244226559997,
- -0.000795092957559973,
- -0.007938209921121597,
- 0.208413764834404,
- -0.00019127204723190516,
- -0.00020650937221944332
- ],
- [
- -0.0020483459811657667,
- -0.0003764357534237206,
- -0.0033135139383375645,
- -0.009666135534644127,
- -0.00031723169377073646,
- -0.005141589790582657,
- 0.31717124581336975,
- 0.0028427678626030684,
- 0.0004723234742414206,
- -0.0011529687326401472,
- 0.2726709246635437,
- -0.003175639547407627
- ],
- [
- -0.00043929810635745525,
- 5.7089622714556754e-05,
- -0.0020629793871194124,
- 0.020066648721694946,
- -0.007871017791330814,
- 0.011316264048218727,
- 0.003056862158700824,
- 0.06856372952461243,
- -0.002747517777606845,
- -0.009279227815568447,
- 0.000506624230183661,
- -0.0013159140944480896
- ],
- [
- -0.012957162223756313,
- -0.0030454176012426615,
- -0.01792328804731369,
- -0.0043589151464402676,
- -0.0011521632550284266,
- 0.0004999117809347808,
- -0.0031131464056670666,
- 0.019585633650422096,
- 4.34632929682266e-05,
- 0.01297028549015522,
- -0.007695754989981651,
- -0.0009146086522378027
- ],
- [
- 0.004100752994418144,
- -0.020459463819861412,
- -0.035875942558050156,
- 0.014656225219368935,
- 0.0008441276149824262,
- 0.0017804511589929461,
- -0.01804223284125328,
- 0.003519016318023205,
- 0.008253024891018867,
- -0.0017665562918409705,
- 0.044167667627334595,
- 0.006474285386502743
- ]
- ]
- }
- ],
- "layout": {
- "coloraxis": {
- "cmid": 0,
- "colorscale": [
- [
- 0,
- "rgb(103,0,31)"
- ],
- [
- 0.1,
- "rgb(178,24,43)"
- ],
- [
- 0.2,
- "rgb(214,96,77)"
- ],
- [
- 0.3,
- "rgb(244,165,130)"
- ],
- [
- 0.4,
- "rgb(253,219,199)"
- ],
- [
- 0.5,
- "rgb(247,247,247)"
- ],
- [
- 0.6,
- "rgb(209,229,240)"
- ],
- [
- 0.7,
- "rgb(146,197,222)"
- ],
- [
- 0.8,
- "rgb(67,147,195)"
- ],
- [
- 0.9,
- "rgb(33,102,172)"
- ],
- [
- 1,
- "rgb(5,48,97)"
- ]
- ]
- },
- "template": {
- "data": {
- "bar": [
- {
- "error_x": {
- "color": "#2a3f5f"
- },
- "error_y": {
- "color": "#2a3f5f"
- },
- "marker": {
- "line": {
- "color": "#E5ECF6",
- "width": 0.5
- },
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "bar"
- }
- ],
- "barpolar": [
- {
- "marker": {
- "line": {
- "color": "#E5ECF6",
- "width": 0.5
- },
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "barpolar"
- }
- ],
- "carpet": [
- {
- "aaxis": {
- "endlinecolor": "#2a3f5f",
- "gridcolor": "white",
- "linecolor": "white",
- "minorgridcolor": "white",
- "startlinecolor": "#2a3f5f"
- },
- "baxis": {
- "endlinecolor": "#2a3f5f",
- "gridcolor": "white",
- "linecolor": "white",
- "minorgridcolor": "white",
- "startlinecolor": "#2a3f5f"
- },
- "type": "carpet"
- }
- ],
- "choropleth": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "choropleth"
- }
- ],
- "contour": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "contour"
- }
- ],
- "contourcarpet": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "contourcarpet"
- }
- ],
- "heatmap": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "heatmap"
- }
- ],
- "heatmapgl": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "heatmapgl"
- }
- ],
- "histogram": [
- {
- "marker": {
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "histogram"
- }
- ],
- "histogram2d": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "histogram2d"
- }
- ],
- "histogram2dcontour": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "histogram2dcontour"
- }
- ],
- "mesh3d": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "mesh3d"
- }
- ],
- "parcoords": [
- {
- "line": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "parcoords"
- }
- ],
- "pie": [
- {
- "automargin": true,
- "type": "pie"
- }
- ],
- "scatter": [
- {
- "fillpattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- },
- "type": "scatter"
- }
- ],
- "scatter3d": [
- {
- "line": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatter3d"
- }
- ],
- "scattercarpet": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattercarpet"
- }
- ],
- "scattergeo": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattergeo"
- }
- ],
- "scattergl": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattergl"
- }
- ],
- "scattermapbox": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattermapbox"
- }
- ],
- "scatterpolar": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterpolar"
- }
- ],
- "scatterpolargl": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterpolargl"
- }
- ],
- "scatterternary": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterternary"
- }
- ],
- "surface": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "surface"
- }
- ],
- "table": [
- {
- "cells": {
- "fill": {
- "color": "#EBF0F8"
- },
- "line": {
- "color": "white"
- }
- },
- "header": {
- "fill": {
- "color": "#C8D4E3"
- },
- "line": {
- "color": "white"
- }
- },
- "type": "table"
- }
- ]
- },
- "layout": {
- "annotationdefaults": {
- "arrowcolor": "#2a3f5f",
- "arrowhead": 0,
- "arrowwidth": 1
- },
- "autotypenumbers": "strict",
- "coloraxis": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "colorscale": {
- "diverging": [
- [
- 0,
- "#8e0152"
- ],
- [
- 0.1,
- "#c51b7d"
- ],
- [
- 0.2,
- "#de77ae"
- ],
- [
- 0.3,
- "#f1b6da"
- ],
- [
- 0.4,
- "#fde0ef"
- ],
- [
- 0.5,
- "#f7f7f7"
- ],
- [
- 0.6,
- "#e6f5d0"
- ],
- [
- 0.7,
- "#b8e186"
- ],
- [
- 0.8,
- "#7fbc41"
- ],
- [
- 0.9,
- "#4d9221"
- ],
- [
- 1,
- "#276419"
- ]
- ],
- "sequential": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "sequentialminus": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ]
- },
- "colorway": [
- "#636efa",
- "#EF553B",
- "#00cc96",
- "#ab63fa",
- "#FFA15A",
- "#19d3f3",
- "#FF6692",
- "#B6E880",
- "#FF97FF",
- "#FECB52"
- ],
- "font": {
- "color": "#2a3f5f"
- },
- "geo": {
- "bgcolor": "white",
- "lakecolor": "white",
- "landcolor": "#E5ECF6",
- "showlakes": true,
- "showland": true,
- "subunitcolor": "white"
- },
- "hoverlabel": {
- "align": "left"
- },
- "hovermode": "closest",
- "mapbox": {
- "style": "light"
- },
- "paper_bgcolor": "white",
- "plot_bgcolor": "#E5ECF6",
- "polar": {
- "angularaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "bgcolor": "#E5ECF6",
- "radialaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- }
- },
- "scene": {
- "xaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- },
- "yaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- },
- "zaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- }
- },
- "shapedefaults": {
- "line": {
- "color": "#2a3f5f"
- }
- },
- "ternary": {
- "aaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "baxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "bgcolor": "#E5ECF6",
- "caxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- }
- },
- "title": {
- "x": 0.05
- },
- "xaxis": {
- "automargin": true,
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": "",
- "title": {
- "standoff": 15
- },
- "zerolinecolor": "white",
- "zerolinewidth": 2
- },
- "yaxis": {
- "automargin": true,
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": "",
- "title": {
- "standoff": 15
- },
- "zerolinecolor": "white",
- "zerolinewidth": 2
- }
- }
- },
- "title": {
- "text": "Logit Difference From Patched Head Value"
- },
- "xaxis": {
- "anchor": "y",
- "constrain": "domain",
- "domain": [
- 0,
- 1
- ],
- "scaleanchor": "y",
- "title": {
- "text": "Head"
- }
- },
- "yaxis": {
- "anchor": "x",
- "autorange": "reversed",
- "constrain": "domain",
- "domain": [
- 0,
- 1
- ],
- "title": {
- "text": "Layer"
- }
- }
- }
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"imshow(\n",
" patched_head_v_diff,\n",
@@ -10072,1523 +1296,9 @@
},
{
"cell_type": "code",
- "execution_count": 30,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "application/vnd.plotly.v1+json": {
- "config": {
- "plotlyServerURL": "https://plot.ly"
- },
- "data": [
- {
- "hovertemplate": "%{hovertext}
Value Patch=%{x}
Output Patch=%{y}
Layer=%{marker.color}",
- "hovertext": [
- "L0H0",
- "L0H1",
- "L0H2",
- "L0H3",
- "L0H4",
- "L0H5",
- "L0H6",
- "L0H7",
- "L0H8",
- "L0H9",
- "L0H10",
- "L0H11",
- "L1H0",
- "L1H1",
- "L1H2",
- "L1H3",
- "L1H4",
- "L1H5",
- "L1H6",
- "L1H7",
- "L1H8",
- "L1H9",
- "L1H10",
- "L1H11",
- "L2H0",
- "L2H1",
- "L2H2",
- "L2H3",
- "L2H4",
- "L2H5",
- "L2H6",
- "L2H7",
- "L2H8",
- "L2H9",
- "L2H10",
- "L2H11",
- "L3H0",
- "L3H1",
- "L3H2",
- "L3H3",
- "L3H4",
- "L3H5",
- "L3H6",
- "L3H7",
- "L3H8",
- "L3H9",
- "L3H10",
- "L3H11",
- "L4H0",
- "L4H1",
- "L4H2",
- "L4H3",
- "L4H4",
- "L4H5",
- "L4H6",
- "L4H7",
- "L4H8",
- "L4H9",
- "L4H10",
- "L4H11",
- "L5H0",
- "L5H1",
- "L5H2",
- "L5H3",
- "L5H4",
- "L5H5",
- "L5H6",
- "L5H7",
- "L5H8",
- "L5H9",
- "L5H10",
- "L5H11",
- "L6H0",
- "L6H1",
- "L6H2",
- "L6H3",
- "L6H4",
- "L6H5",
- "L6H6",
- "L6H7",
- "L6H8",
- "L6H9",
- "L6H10",
- "L6H11",
- "L7H0",
- "L7H1",
- "L7H2",
- "L7H3",
- "L7H4",
- "L7H5",
- "L7H6",
- "L7H7",
- "L7H8",
- "L7H9",
- "L7H10",
- "L7H11",
- "L8H0",
- "L8H1",
- "L8H2",
- "L8H3",
- "L8H4",
- "L8H5",
- "L8H6",
- "L8H7",
- "L8H8",
- "L8H9",
- "L8H10",
- "L8H11",
- "L9H0",
- "L9H1",
- "L9H2",
- "L9H3",
- "L9H4",
- "L9H5",
- "L9H6",
- "L9H7",
- "L9H8",
- "L9H9",
- "L9H10",
- "L9H11",
- "L10H0",
- "L10H1",
- "L10H2",
- "L10H3",
- "L10H4",
- "L10H5",
- "L10H6",
- "L10H7",
- "L10H8",
- "L10H9",
- "L10H10",
- "L10H11",
- "L11H0",
- "L11H1",
- "L11H2",
- "L11H3",
- "L11H4",
- "L11H5",
- "L11H6",
- "L11H7",
- "L11H8",
- "L11H9",
- "L11H10",
- "L11H11"
- ],
- "legendgroup": "",
- "marker": {
- "color": [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 2,
- 2,
- 2,
- 2,
- 2,
- 2,
- 2,
- 2,
- 2,
- 2,
- 2,
- 2,
- 3,
- 3,
- 3,
- 3,
- 3,
- 3,
- 3,
- 3,
- 3,
- 3,
- 3,
- 3,
- 4,
- 4,
- 4,
- 4,
- 4,
- 4,
- 4,
- 4,
- 4,
- 4,
- 4,
- 4,
- 5,
- 5,
- 5,
- 5,
- 5,
- 5,
- 5,
- 5,
- 5,
- 5,
- 5,
- 5,
- 6,
- 6,
- 6,
- 6,
- 6,
- 6,
- 6,
- 6,
- 6,
- 6,
- 6,
- 6,
- 7,
- 7,
- 7,
- 7,
- 7,
- 7,
- 7,
- 7,
- 7,
- 7,
- 7,
- 7,
- 8,
- 8,
- 8,
- 8,
- 8,
- 8,
- 8,
- 8,
- 8,
- 8,
- 8,
- 8,
- 9,
- 9,
- 9,
- 9,
- 9,
- 9,
- 9,
- 9,
- 9,
- 9,
- 9,
- 9,
- 10,
- 10,
- 10,
- 10,
- 10,
- 10,
- 10,
- 10,
- 10,
- 10,
- 10,
- 10,
- 11,
- 11,
- 11,
- 11,
- 11,
- 11,
- 11,
- 11,
- 11,
- 11,
- 11,
- 11
- ],
- "coloraxis": "coloraxis",
- "symbol": "circle"
- },
- "mode": "markers",
- "name": "",
- "orientation": "v",
- "showlegend": false,
- "type": "scatter",
- "x": [
- -0.00019892427371814847,
- 0.005339574534446001,
- 0.0006527548539452255,
- 0.003504416672512889,
- -0.00898387935012579,
- 0.0034814265090972185,
- -0.0008631910313852131,
- -3.406582254683599e-05,
- 0.0005166929331608117,
- 0.00044255363172851503,
- -0.0039068968035280704,
- -0.0001880836207419634,
- -0.0004399022145662457,
- -0.00044510437874123454,
- -6.73597096465528e-05,
- 7.242763240355998e-05,
- -3.6549441574607044e-05,
- -0.0019323208834975958,
- -0.0001572397886775434,
- 1.6143509128596634e-05,
- 0.00020593880617525429,
- 0.000336798548232764,
- 0.0003515324497129768,
- -0.0005669358652085066,
- 0.00021013410878367722,
- -0.0007199132232926786,
- 0.0004868560063187033,
- -0.0005974104860797524,
- -0.0005921411793678999,
- -0.0005443819100037217,
- -0.000227552984142676,
- -0.0004809825913980603,
- 0.00020570388005580753,
- 0.001183376181870699,
- -0.0003574058646336198,
- -0.0009104468626901507,
- 0.0010395278222858906,
- -0.00012042184971505776,
- -7.762980385450646e-05,
- -0.0007275318494066596,
- -0.001310007064603269,
- -0.0023108376190066338,
- 0.010987084358930588,
- -5.0712766096694395e-05,
- 0.00014314358122646809,
- 0.00015069512301124632,
- -7.957642083056271e-05,
- -2.0238119759596884e-05,
- -0.0005373673629947007,
- -0.0008137872209772468,
- -0.00013334336108528078,
- 0.030609702691435814,
- -0.007185807917267084,
- 0.000148916311445646,
- 0.0013340713921934366,
- -0.01142292469739914,
- -0.0005336419562809169,
- 0.0005126654868945479,
- 0.00037344868178479373,
- 0.0029547319281846285,
- 8.22278525447473e-06,
- 6.477540864580078e-06,
- 0.0015973682748153806,
- 0.00034015480196103454,
- -0.0012577504385262728,
- -5.450531898532063e-05,
- 0.0006331544718705118,
- -0.00027081489679403603,
- 7.427356467815116e-05,
- -0.006704355590045452,
- 0.003175975289195776,
- -0.0017300404142588377,
- 0.04863045737147331,
- 0.015314852818846703,
- -0.0004648726317100227,
- -0.00011676354915834963,
- -4.930314753437415e-05,
- -0.003952810075134039,
- -0.01737578585743904,
- -0.00015421917487401515,
- 0.0012194222072139382,
- -0.00018090127559844404,
- -0.00042647725786082447,
- 0.00012334177154116333,
- -2.956846401502844e-05,
- -0.0013855225406587124,
- -0.00012129446986364201,
- 0.1332160234451294,
- -0.00024490474606864154,
- -0.007315828464925289,
- 0.00033297244226559997,
- -0.000795092957559973,
- -0.007938209921121597,
- 0.208413764834404,
- -0.00019127204723190516,
- -0.00020650937221944332,
- -0.0020483459811657667,
- -0.0003764357534237206,
- -0.0033135139383375645,
- -0.009666135534644127,
- -0.00031723169377073646,
- -0.005141589790582657,
- 0.31717124581336975,
- 0.0028427678626030684,
- 0.0004723234742414206,
- -0.0011529687326401472,
- 0.2726709246635437,
- -0.003175639547407627,
- -0.00043929810635745525,
- 5.7089622714556754e-05,
- -0.0020629793871194124,
- 0.020066648721694946,
- -0.007871017791330814,
- 0.011316264048218727,
- 0.003056862158700824,
- 0.06856372952461243,
- -0.002747517777606845,
- -0.009279227815568447,
- 0.000506624230183661,
- -0.0013159140944480896,
- -0.012957162223756313,
- -0.0030454176012426615,
- -0.01792328804731369,
- -0.0043589151464402676,
- -0.0011521632550284266,
- 0.0004999117809347808,
- -0.0031131464056670666,
- 0.019585633650422096,
- 4.34632929682266e-05,
- 0.01297028549015522,
- -0.007695754989981651,
- -0.0009146086522378027,
- 0.004100752994418144,
- -0.020459463819861412,
- -0.035875942558050156,
- 0.014656225219368935,
- 0.0008441276149824262,
- 0.0017804511589929461,
- -0.01804223284125328,
- 0.003519016318023205,
- 0.008253024891018867,
- -0.0017665562918409705,
- 0.044167667627334595,
- 0.006474285386502743
- ],
- "xaxis": "x",
- "y": [
- 0.0009487751522101462,
- 0.016124747693538666,
- 0.0018548924708738923,
- 0.0034389030188322067,
- -0.00982347596436739,
- 0.011058605276048183,
- -0.004063969012349844,
- -0.0015792781487107277,
- -0.0012082795146852732,
- 0.003828897839412093,
- -0.004256919026374817,
- -0.0011422622483223677,
- -0.0010771177476271987,
- -0.00037898647133260965,
- 2.5171791548928013e-06,
- -0.00026067905128002167,
- -0.00014146546891424805,
- 0.0038321535103023052,
- -0.0004293300735298544,
- -0.00142992555629462,
- -0.0009228314156644046,
- 0.0006944393389858305,
- 0.00043302192352712154,
- -0.0035714071709662676,
- -0.0004967569257132709,
- 0.0008057993836700916,
- 0.0005424688570201397,
- -0.0005309234256856143,
- -0.0007159864180721343,
- -0.0010389237431809306,
- -0.0009490771917626262,
- -8.649027586216107e-05,
- 0.0002766547549981624,
- 0.0021084228064864874,
- -0.0001975146442418918,
- -0.0016405630158260465,
- 0.1162627637386322,
- 0.0002507446042727679,
- -0.0014675153652206063,
- -0.00039680811460129917,
- 0.018962211906909943,
- -0.00018764731066767126,
- 0.011170871555805206,
- -0.0013301445869728923,
- -0.0007356539717875421,
- -0.00030253134900704026,
- -0.00014683544577565044,
- -0.00022228369198273867,
- -0.001650598249398172,
- 0.0002927311579696834,
- -0.00143563118763268,
- 0.03084198758006096,
- -0.007432155776768923,
- -0.00028236035723239183,
- 0.006017433945089579,
- -0.011007187888026237,
- -0.001266107545234263,
- 0.0014901700196787715,
- -0.0001800622121663764,
- 0.002944394713267684,
- -0.004211106337606907,
- 0.0029597999528050423,
- 0.002045023487880826,
- 0.0013397098518908024,
- -0.0012190865818411112,
- 0.34349915385246277,
- 0.0005632104002870619,
- -0.0001262281439267099,
- -0.00515326950699091,
- 0.016240738332271576,
- 0.01709030382335186,
- -0.004175194539129734,
- 0.039775289595127106,
- 0.015226684510707855,
- -0.0010229480685666203,
- 0.0008072761120274663,
- -0.004935584031045437,
- -0.002123525831848383,
- -0.014274083077907562,
- 0.0013746818294748664,
- 0.0014838266652077436,
- 0.1302703619003296,
- -0.00033616088330745697,
- 0.0012919505825266242,
- 0.00037177055492065847,
- 0.019514480605721474,
- 0.00022255218937061727,
- 0.124249167740345,
- -0.00040352059295400977,
- -0.007652895525097847,
- 0.0013010123511776328,
- -0.0011253133416175842,
- -0.007449474185705185,
- 0.19224143028259277,
- -0.003275118535384536,
- -0.0005017912480980158,
- -0.001007912098430097,
- 3.091096004936844e-05,
- -0.0008595998515374959,
- 0.012359987013041973,
- -0.0004041247011628002,
- -0.004328910261392593,
- 0.3185553252696991,
- 0.002330605871975422,
- 0.0021182901691645384,
- 0.0001405928487656638,
- 0.2779357433319092,
- 0.005738262087106705,
- 0.0058898297138512135,
- -0.0009689796715974808,
- 0.00912561360746622,
- 0.020675739273428917,
- -0.03700518235564232,
- 0.014263041317462921,
- -0.04828466475009918,
- 0.05834139883518219,
- 0.0006514795240946114,
- 0.26360899209976196,
- 0.0004918567719869316,
- -0.00261044898070395,
- 0.08374208211898804,
- 0.020676210522651672,
- -0.003743582172319293,
- 0.01085072010755539,
- -0.001096583902835846,
- 0.00047430366976186633,
- 0.04818058758974075,
- -0.4799128472805023,
- 0.00018429107149131596,
- 0.011861988343298435,
- 0.06088569387793541,
- 0.0008461413672193885,
- 0.005328264087438583,
- -0.011493473313748837,
- -0.11350836604833603,
- 0.006329597905278206,
- 0.00031669469899497926,
- -0.0011600167490541935,
- -0.022669579833745956,
- 0.004070379305630922,
- 0.0073160636238753796,
- -0.00834545586258173,
- -0.27817651629447937,
- 0.0036344374530017376
- ],
- "yaxis": "y"
- }
- ],
- "layout": {
- "coloraxis": {
- "colorbar": {
- "title": {
- "text": "Layer"
- }
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ]
- },
- "legend": {
- "tracegroupgap": 0
- },
- "template": {
- "data": {
- "bar": [
- {
- "error_x": {
- "color": "#2a3f5f"
- },
- "error_y": {
- "color": "#2a3f5f"
- },
- "marker": {
- "line": {
- "color": "#E5ECF6",
- "width": 0.5
- },
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "bar"
- }
- ],
- "barpolar": [
- {
- "marker": {
- "line": {
- "color": "#E5ECF6",
- "width": 0.5
- },
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "barpolar"
- }
- ],
- "carpet": [
- {
- "aaxis": {
- "endlinecolor": "#2a3f5f",
- "gridcolor": "white",
- "linecolor": "white",
- "minorgridcolor": "white",
- "startlinecolor": "#2a3f5f"
- },
- "baxis": {
- "endlinecolor": "#2a3f5f",
- "gridcolor": "white",
- "linecolor": "white",
- "minorgridcolor": "white",
- "startlinecolor": "#2a3f5f"
- },
- "type": "carpet"
- }
- ],
- "choropleth": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "choropleth"
- }
- ],
- "contour": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "contour"
- }
- ],
- "contourcarpet": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "contourcarpet"
- }
- ],
- "heatmap": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "heatmap"
- }
- ],
- "heatmapgl": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "heatmapgl"
- }
- ],
- "histogram": [
- {
- "marker": {
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "histogram"
- }
- ],
- "histogram2d": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "histogram2d"
- }
- ],
- "histogram2dcontour": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "histogram2dcontour"
- }
- ],
- "mesh3d": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "mesh3d"
- }
- ],
- "parcoords": [
- {
- "line": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "parcoords"
- }
- ],
- "pie": [
- {
- "automargin": true,
- "type": "pie"
- }
- ],
- "scatter": [
- {
- "fillpattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- },
- "type": "scatter"
- }
- ],
- "scatter3d": [
- {
- "line": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatter3d"
- }
- ],
- "scattercarpet": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattercarpet"
- }
- ],
- "scattergeo": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattergeo"
- }
- ],
- "scattergl": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattergl"
- }
- ],
- "scattermapbox": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattermapbox"
- }
- ],
- "scatterpolar": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterpolar"
- }
- ],
- "scatterpolargl": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterpolargl"
- }
- ],
- "scatterternary": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterternary"
- }
- ],
- "surface": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "surface"
- }
- ],
- "table": [
- {
- "cells": {
- "fill": {
- "color": "#EBF0F8"
- },
- "line": {
- "color": "white"
- }
- },
- "header": {
- "fill": {
- "color": "#C8D4E3"
- },
- "line": {
- "color": "white"
- }
- },
- "type": "table"
- }
- ]
- },
- "layout": {
- "annotationdefaults": {
- "arrowcolor": "#2a3f5f",
- "arrowhead": 0,
- "arrowwidth": 1
- },
- "autotypenumbers": "strict",
- "coloraxis": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "colorscale": {
- "diverging": [
- [
- 0,
- "#8e0152"
- ],
- [
- 0.1,
- "#c51b7d"
- ],
- [
- 0.2,
- "#de77ae"
- ],
- [
- 0.3,
- "#f1b6da"
- ],
- [
- 0.4,
- "#fde0ef"
- ],
- [
- 0.5,
- "#f7f7f7"
- ],
- [
- 0.6,
- "#e6f5d0"
- ],
- [
- 0.7,
- "#b8e186"
- ],
- [
- 0.8,
- "#7fbc41"
- ],
- [
- 0.9,
- "#4d9221"
- ],
- [
- 1,
- "#276419"
- ]
- ],
- "sequential": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "sequentialminus": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ]
- },
- "colorway": [
- "#636efa",
- "#EF553B",
- "#00cc96",
- "#ab63fa",
- "#FFA15A",
- "#19d3f3",
- "#FF6692",
- "#B6E880",
- "#FF97FF",
- "#FECB52"
- ],
- "font": {
- "color": "#2a3f5f"
- },
- "geo": {
- "bgcolor": "white",
- "lakecolor": "white",
- "landcolor": "#E5ECF6",
- "showlakes": true,
- "showland": true,
- "subunitcolor": "white"
- },
- "hoverlabel": {
- "align": "left"
- },
- "hovermode": "closest",
- "mapbox": {
- "style": "light"
- },
- "paper_bgcolor": "white",
- "plot_bgcolor": "#E5ECF6",
- "polar": {
- "angularaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "bgcolor": "#E5ECF6",
- "radialaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- }
- },
- "scene": {
- "xaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- },
- "yaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- },
- "zaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- }
- },
- "shapedefaults": {
- "line": {
- "color": "#2a3f5f"
- }
- },
- "ternary": {
- "aaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "baxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "bgcolor": "#E5ECF6",
- "caxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- }
- },
- "title": {
- "x": 0.05
- },
- "xaxis": {
- "automargin": true,
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": "",
- "title": {
- "standoff": 15
- },
- "zerolinecolor": "white",
- "zerolinewidth": 2
- },
- "yaxis": {
- "automargin": true,
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": "",
- "title": {
- "standoff": 15
- },
- "zerolinecolor": "white",
- "zerolinewidth": 2
- }
- }
- },
- "title": {
- "text": "Scatter plot of output patching vs value patching"
- },
- "xaxis": {
- "anchor": "y",
- "domain": [
- 0,
- 1
- ],
- "range": [
- -0.5,
- 0.5
- ],
- "title": {
- "text": "Value Patch"
- }
- },
- "yaxis": {
- "anchor": "x",
- "domain": [
- 0,
- 1
- ],
- "range": [
- -0.5,
- 0.5
- ],
- "title": {
- "text": "Output Patch"
- }
- }
- }
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"head_labels = [\n",
" f\"L{l}H{h}\" for l in range(model.cfg.n_layers) for h in range(model.cfg.n_heads)\n",
@@ -11619,7 +1329,7 @@
},
{
"cell_type": "code",
- "execution_count": 31,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -11629,9 +1339,11 @@
" head_index,\n",
" clean_cache,\n",
"):\n",
- " corrupted_head_pattern[:, head_index, :, :] = clean_cache[hook.name][\n",
+ " clean_value = clean_cache[hook.name][\n",
" :, head_index, :, :\n",
- " ]\n",
+ " ].clone()\n",
+ " corrupted_head_pattern = corrupted_head_pattern.clone()\n",
+ " corrupted_head_pattern[:, head_index : head_index + 1, :, :] = clean_value.unsqueeze(1)\n",
" return corrupted_head_pattern\n",
"\n",
"\n",
@@ -11655,2405 +1367,9 @@
},
{
"cell_type": "code",
- "execution_count": 32,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "application/vnd.plotly.v1+json": {
- "config": {
- "plotlyServerURL": "https://plot.ly"
- },
- "data": [
- {
- "coloraxis": "coloraxis",
- "hovertemplate": "Head: %{x}
Layer: %{y}
color: %{z}",
- "name": "0",
- "type": "heatmap",
- "xaxis": "x",
- "yaxis": "y",
- "z": [
- [
- 0.0006401354330591857,
- 0.005318799521774054,
- 0.0011584057938307524,
- -5.920405237702653e-05,
- -0.00106671336106956,
- 0.005079298280179501,
- -0.0030818663071841,
- -0.0020521720871329308,
- -0.0014405983965843916,
- 0.003492669900879264,
- -0.002568227471783757,
- -0.0009168237447738647
- ],
- [
- -0.0007600873941555619,
- 0.0001683824957581237,
- 0.00012246915139257908,
- -0.00034914951538667083,
- 1.4901700524205808e-05,
- 0.0050090523436665535,
- -0.0002975976967718452,
- -0.0014448943547904491,
- -0.001099134678952396,
- 0.00047447148244827986,
- 5.195457561057992e-05,
- -0.0034954219590872526
- ],
- [
- -0.0007243098807521164,
- 0.0017458146903663874,
- -0.00015556166181340814,
- 5.7626621128292754e-05,
- -9.7398049547337e-05,
- -0.0004238593974150717,
- -0.0007917031762190163,
- 0.00027222454082220793,
- 0.00010179472155869007,
- 0.0004223826399538666,
- 0.00015193692524917424,
- -0.0007437760941684246
- ],
- [
- 0.11458104848861694,
- 0.00021140948229003698,
- -0.0009424989693798125,
- 0.000429833511589095,
- 0.02004295401275158,
- 0.002104730810970068,
- 7.628730963915586e-05,
- -0.001543701975606382,
- -0.0008484235731884837,
- -0.0005819046637043357,
- 0.00011921360419364646,
- -1.899631206470076e-05
- ],
- [
- -0.001127125695347786,
- 0.001237143180333078,
- -0.0012324444251134992,
- -0.0005952289211563766,
- -0.0007541133090853691,
- -0.0005842540413141251,
- 0.004813014063984156,
- 0.00018187458044849336,
- -0.0005361591465771198,
- 0.0008579217828810215,
- -0.0002985374303534627,
- -1.144477391790133e-05
- ],
- [
- -0.004241178277879953,
- 0.0029509058222174644,
- 0.0005218615406192839,
- 0.0009535074350424111,
- 0.0001622070267330855,
- 0.34350839257240295,
- -0.0003052163519896567,
- 0.00010293584637111053,
- -0.005300541408360004,
- 0.024864863604307175,
- 0.014383262023329735,
- -0.0023285921197384596
- ],
- [
- -0.0023893399629741907,
- -0.002172795357182622,
- -0.00047614958020858467,
- 0.00043188079143874347,
- -0.004675475414842367,
- 0.0018583494238555431,
- -0.0026542814448475838,
- 0.0014367386465892196,
- 0.00030326974228955805,
- 0.13043038547039032,
- 8.813483145786449e-05,
- 0.0011766973184421659
- ],
- [
- 0.00031847349600866437,
- 0.02057075686752796,
- 0.00031840638257563114,
- -0.002512782346457243,
- -0.0002628941729199141,
- -0.00024718698114156723,
- 0.0005524033331312239,
- -0.00043131023994646966,
- 0.00025715501396916807,
- 0.008090951479971409,
- -0.0030689111445099115,
- -0.0004238593974150717
- ],
- [
- 0.000976699055172503,
- 0.00039251212729141116,
- 0.0017534669023007154,
- 0.022595642134547234,
- -4.4805787183577195e-05,
- 0.00014220383309293538,
- 0.009584981948137283,
- -0.0003157213795930147,
- 0.0015271222218871117,
- 0.0011813960736617446,
- -0.010774029418826103,
- 0.00936581939458847
- ],
- [
- 0.006314125377684832,
- -0.0010949057759717107,
- 0.011662023141980171,
- 0.0013481340138241649,
- -0.02918696030974388,
- 0.0038333951961249113,
- -0.04409456625580788,
- -0.005032042507082224,
- 0.00482167350128293,
- 0.2766477167606354,
- -3.164933150401339e-05,
- -0.0006618167390115559
- ],
- [
- 0.0953889712691307,
- 0.02506939135491848,
- 0.014239178970456123,
- 0.014754998497664928,
- 9.890835644910112e-05,
- -8.977938705356792e-05,
- 0.05082912743091583,
- -0.5051022171974182,
- 0.00014696970174554735,
- -0.0016026375815272331,
- 0.06883199512958527,
- 0.002327115274965763
- ],
- [
- 0.0013425961369648576,
- 0.009630928747355938,
- -0.07776415348052979,
- -0.007728713098913431,
- -0.0005726079107262194,
- -0.002957182005047798,
- -0.0049475994892418385,
- 0.00045916702947579324,
- -0.0006328188464976847,
- -0.006520198658108711,
- -0.3204910457134247,
- -0.002473111730068922
- ]
- ]
- }
- ],
- "layout": {
- "coloraxis": {
- "cmid": 0,
- "colorscale": [
- [
- 0,
- "rgb(103,0,31)"
- ],
- [
- 0.1,
- "rgb(178,24,43)"
- ],
- [
- 0.2,
- "rgb(214,96,77)"
- ],
- [
- 0.3,
- "rgb(244,165,130)"
- ],
- [
- 0.4,
- "rgb(253,219,199)"
- ],
- [
- 0.5,
- "rgb(247,247,247)"
- ],
- [
- 0.6,
- "rgb(209,229,240)"
- ],
- [
- 0.7,
- "rgb(146,197,222)"
- ],
- [
- 0.8,
- "rgb(67,147,195)"
- ],
- [
- 0.9,
- "rgb(33,102,172)"
- ],
- [
- 1,
- "rgb(5,48,97)"
- ]
- ]
- },
- "template": {
- "data": {
- "bar": [
- {
- "error_x": {
- "color": "#2a3f5f"
- },
- "error_y": {
- "color": "#2a3f5f"
- },
- "marker": {
- "line": {
- "color": "#E5ECF6",
- "width": 0.5
- },
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "bar"
- }
- ],
- "barpolar": [
- {
- "marker": {
- "line": {
- "color": "#E5ECF6",
- "width": 0.5
- },
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "barpolar"
- }
- ],
- "carpet": [
- {
- "aaxis": {
- "endlinecolor": "#2a3f5f",
- "gridcolor": "white",
- "linecolor": "white",
- "minorgridcolor": "white",
- "startlinecolor": "#2a3f5f"
- },
- "baxis": {
- "endlinecolor": "#2a3f5f",
- "gridcolor": "white",
- "linecolor": "white",
- "minorgridcolor": "white",
- "startlinecolor": "#2a3f5f"
- },
- "type": "carpet"
- }
- ],
- "choropleth": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "choropleth"
- }
- ],
- "contour": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "contour"
- }
- ],
- "contourcarpet": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "contourcarpet"
- }
- ],
- "heatmap": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "heatmap"
- }
- ],
- "heatmapgl": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "heatmapgl"
- }
- ],
- "histogram": [
- {
- "marker": {
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "histogram"
- }
- ],
- "histogram2d": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "histogram2d"
- }
- ],
- "histogram2dcontour": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "histogram2dcontour"
- }
- ],
- "mesh3d": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "mesh3d"
- }
- ],
- "parcoords": [
- {
- "line": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "parcoords"
- }
- ],
- "pie": [
- {
- "automargin": true,
- "type": "pie"
- }
- ],
- "scatter": [
- {
- "fillpattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- },
- "type": "scatter"
- }
- ],
- "scatter3d": [
- {
- "line": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatter3d"
- }
- ],
- "scattercarpet": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattercarpet"
- }
- ],
- "scattergeo": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattergeo"
- }
- ],
- "scattergl": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattergl"
- }
- ],
- "scattermapbox": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattermapbox"
- }
- ],
- "scatterpolar": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterpolar"
- }
- ],
- "scatterpolargl": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterpolargl"
- }
- ],
- "scatterternary": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterternary"
- }
- ],
- "surface": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "surface"
- }
- ],
- "table": [
- {
- "cells": {
- "fill": {
- "color": "#EBF0F8"
- },
- "line": {
- "color": "white"
- }
- },
- "header": {
- "fill": {
- "color": "#C8D4E3"
- },
- "line": {
- "color": "white"
- }
- },
- "type": "table"
- }
- ]
- },
- "layout": {
- "annotationdefaults": {
- "arrowcolor": "#2a3f5f",
- "arrowhead": 0,
- "arrowwidth": 1
- },
- "autotypenumbers": "strict",
- "coloraxis": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "colorscale": {
- "diverging": [
- [
- 0,
- "#8e0152"
- ],
- [
- 0.1,
- "#c51b7d"
- ],
- [
- 0.2,
- "#de77ae"
- ],
- [
- 0.3,
- "#f1b6da"
- ],
- [
- 0.4,
- "#fde0ef"
- ],
- [
- 0.5,
- "#f7f7f7"
- ],
- [
- 0.6,
- "#e6f5d0"
- ],
- [
- 0.7,
- "#b8e186"
- ],
- [
- 0.8,
- "#7fbc41"
- ],
- [
- 0.9,
- "#4d9221"
- ],
- [
- 1,
- "#276419"
- ]
- ],
- "sequential": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "sequentialminus": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ]
- },
- "colorway": [
- "#636efa",
- "#EF553B",
- "#00cc96",
- "#ab63fa",
- "#FFA15A",
- "#19d3f3",
- "#FF6692",
- "#B6E880",
- "#FF97FF",
- "#FECB52"
- ],
- "font": {
- "color": "#2a3f5f"
- },
- "geo": {
- "bgcolor": "white",
- "lakecolor": "white",
- "landcolor": "#E5ECF6",
- "showlakes": true,
- "showland": true,
- "subunitcolor": "white"
- },
- "hoverlabel": {
- "align": "left"
- },
- "hovermode": "closest",
- "mapbox": {
- "style": "light"
- },
- "paper_bgcolor": "white",
- "plot_bgcolor": "#E5ECF6",
- "polar": {
- "angularaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "bgcolor": "#E5ECF6",
- "radialaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- }
- },
- "scene": {
- "xaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- },
- "yaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- },
- "zaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- }
- },
- "shapedefaults": {
- "line": {
- "color": "#2a3f5f"
- }
- },
- "ternary": {
- "aaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "baxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "bgcolor": "#E5ECF6",
- "caxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- }
- },
- "title": {
- "x": 0.05
- },
- "xaxis": {
- "automargin": true,
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": "",
- "title": {
- "standoff": 15
- },
- "zerolinecolor": "white",
- "zerolinewidth": 2
- },
- "yaxis": {
- "automargin": true,
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": "",
- "title": {
- "standoff": 15
- },
- "zerolinecolor": "white",
- "zerolinewidth": 2
- }
- }
- },
- "title": {
- "text": "Logit Difference From Patched Head Pattern"
- },
- "xaxis": {
- "anchor": "y",
- "constrain": "domain",
- "domain": [
- 0,
- 1
- ],
- "scaleanchor": "y",
- "title": {
- "text": "Head"
- }
- },
- "yaxis": {
- "anchor": "x",
- "autorange": "reversed",
- "constrain": "domain",
- "domain": [
- 0,
- 1
- ],
- "title": {
- "text": "Layer"
- }
- }
- }
- }
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "application/vnd.plotly.v1+json": {
- "config": {
- "plotlyServerURL": "https://plot.ly"
- },
- "data": [
- {
- "hovertemplate": "%{hovertext}
Attention Patch=%{x}
Output Patch=%{y}",
- "hovertext": [
- "L0H0",
- "L0H1",
- "L0H2",
- "L0H3",
- "L0H4",
- "L0H5",
- "L0H6",
- "L0H7",
- "L0H8",
- "L0H9",
- "L0H10",
- "L0H11",
- "L1H0",
- "L1H1",
- "L1H2",
- "L1H3",
- "L1H4",
- "L1H5",
- "L1H6",
- "L1H7",
- "L1H8",
- "L1H9",
- "L1H10",
- "L1H11",
- "L2H0",
- "L2H1",
- "L2H2",
- "L2H3",
- "L2H4",
- "L2H5",
- "L2H6",
- "L2H7",
- "L2H8",
- "L2H9",
- "L2H10",
- "L2H11",
- "L3H0",
- "L3H1",
- "L3H2",
- "L3H3",
- "L3H4",
- "L3H5",
- "L3H6",
- "L3H7",
- "L3H8",
- "L3H9",
- "L3H10",
- "L3H11",
- "L4H0",
- "L4H1",
- "L4H2",
- "L4H3",
- "L4H4",
- "L4H5",
- "L4H6",
- "L4H7",
- "L4H8",
- "L4H9",
- "L4H10",
- "L4H11",
- "L5H0",
- "L5H1",
- "L5H2",
- "L5H3",
- "L5H4",
- "L5H5",
- "L5H6",
- "L5H7",
- "L5H8",
- "L5H9",
- "L5H10",
- "L5H11",
- "L6H0",
- "L6H1",
- "L6H2",
- "L6H3",
- "L6H4",
- "L6H5",
- "L6H6",
- "L6H7",
- "L6H8",
- "L6H9",
- "L6H10",
- "L6H11",
- "L7H0",
- "L7H1",
- "L7H2",
- "L7H3",
- "L7H4",
- "L7H5",
- "L7H6",
- "L7H7",
- "L7H8",
- "L7H9",
- "L7H10",
- "L7H11",
- "L8H0",
- "L8H1",
- "L8H2",
- "L8H3",
- "L8H4",
- "L8H5",
- "L8H6",
- "L8H7",
- "L8H8",
- "L8H9",
- "L8H10",
- "L8H11",
- "L9H0",
- "L9H1",
- "L9H2",
- "L9H3",
- "L9H4",
- "L9H5",
- "L9H6",
- "L9H7",
- "L9H8",
- "L9H9",
- "L9H10",
- "L9H11",
- "L10H0",
- "L10H1",
- "L10H2",
- "L10H3",
- "L10H4",
- "L10H5",
- "L10H6",
- "L10H7",
- "L10H8",
- "L10H9",
- "L10H10",
- "L10H11",
- "L11H0",
- "L11H1",
- "L11H2",
- "L11H3",
- "L11H4",
- "L11H5",
- "L11H6",
- "L11H7",
- "L11H8",
- "L11H9",
- "L11H10",
- "L11H11"
- ],
- "legendgroup": "",
- "marker": {
- "color": "#636efa",
- "symbol": "circle"
- },
- "mode": "markers",
- "name": "",
- "orientation": "v",
- "showlegend": false,
- "type": "scatter",
- "x": [
- 0.0006401354330591857,
- 0.005318799521774054,
- 0.0011584057938307524,
- -5.920405237702653e-05,
- -0.00106671336106956,
- 0.005079298280179501,
- -0.0030818663071841,
- -0.0020521720871329308,
- -0.0014405983965843916,
- 0.003492669900879264,
- -0.002568227471783757,
- -0.0009168237447738647,
- -0.0007600873941555619,
- 0.0001683824957581237,
- 0.00012246915139257908,
- -0.00034914951538667083,
- 1.4901700524205808e-05,
- 0.0050090523436665535,
- -0.0002975976967718452,
- -0.0014448943547904491,
- -0.001099134678952396,
- 0.00047447148244827986,
- 5.195457561057992e-05,
- -0.0034954219590872526,
- -0.0007243098807521164,
- 0.0017458146903663874,
- -0.00015556166181340814,
- 5.7626621128292754e-05,
- -9.7398049547337e-05,
- -0.0004238593974150717,
- -0.0007917031762190163,
- 0.00027222454082220793,
- 0.00010179472155869007,
- 0.0004223826399538666,
- 0.00015193692524917424,
- -0.0007437760941684246,
- 0.11458104848861694,
- 0.00021140948229003698,
- -0.0009424989693798125,
- 0.000429833511589095,
- 0.02004295401275158,
- 0.002104730810970068,
- 7.628730963915586e-05,
- -0.001543701975606382,
- -0.0008484235731884837,
- -0.0005819046637043357,
- 0.00011921360419364646,
- -1.899631206470076e-05,
- -0.001127125695347786,
- 0.001237143180333078,
- -0.0012324444251134992,
- -0.0005952289211563766,
- -0.0007541133090853691,
- -0.0005842540413141251,
- 0.004813014063984156,
- 0.00018187458044849336,
- -0.0005361591465771198,
- 0.0008579217828810215,
- -0.0002985374303534627,
- -1.144477391790133e-05,
- -0.004241178277879953,
- 0.0029509058222174644,
- 0.0005218615406192839,
- 0.0009535074350424111,
- 0.0001622070267330855,
- 0.34350839257240295,
- -0.0003052163519896567,
- 0.00010293584637111053,
- -0.005300541408360004,
- 0.024864863604307175,
- 0.014383262023329735,
- -0.0023285921197384596,
- -0.0023893399629741907,
- -0.002172795357182622,
- -0.00047614958020858467,
- 0.00043188079143874347,
- -0.004675475414842367,
- 0.0018583494238555431,
- -0.0026542814448475838,
- 0.0014367386465892196,
- 0.00030326974228955805,
- 0.13043038547039032,
- 8.813483145786449e-05,
- 0.0011766973184421659,
- 0.00031847349600866437,
- 0.02057075686752796,
- 0.00031840638257563114,
- -0.002512782346457243,
- -0.0002628941729199141,
- -0.00024718698114156723,
- 0.0005524033331312239,
- -0.00043131023994646966,
- 0.00025715501396916807,
- 0.008090951479971409,
- -0.0030689111445099115,
- -0.0004238593974150717,
- 0.000976699055172503,
- 0.00039251212729141116,
- 0.0017534669023007154,
- 0.022595642134547234,
- -4.4805787183577195e-05,
- 0.00014220383309293538,
- 0.009584981948137283,
- -0.0003157213795930147,
- 0.0015271222218871117,
- 0.0011813960736617446,
- -0.010774029418826103,
- 0.00936581939458847,
- 0.006314125377684832,
- -0.0010949057759717107,
- 0.011662023141980171,
- 0.0013481340138241649,
- -0.02918696030974388,
- 0.0038333951961249113,
- -0.04409456625580788,
- -0.005032042507082224,
- 0.00482167350128293,
- 0.2766477167606354,
- -3.164933150401339e-05,
- -0.0006618167390115559,
- 0.0953889712691307,
- 0.02506939135491848,
- 0.014239178970456123,
- 0.014754998497664928,
- 9.890835644910112e-05,
- -8.977938705356792e-05,
- 0.05082912743091583,
- -0.5051022171974182,
- 0.00014696970174554735,
- -0.0016026375815272331,
- 0.06883199512958527,
- 0.002327115274965763,
- 0.0013425961369648576,
- 0.009630928747355938,
- -0.07776415348052979,
- -0.007728713098913431,
- -0.0005726079107262194,
- -0.002957182005047798,
- -0.0049475994892418385,
- 0.00045916702947579324,
- -0.0006328188464976847,
- -0.006520198658108711,
- -0.3204910457134247,
- -0.002473111730068922
- ],
- "xaxis": "x",
- "y": [
- 0.0009487751522101462,
- 0.016124747693538666,
- 0.0018548924708738923,
- 0.0034389030188322067,
- -0.00982347596436739,
- 0.011058605276048183,
- -0.004063969012349844,
- -0.0015792781487107277,
- -0.0012082795146852732,
- 0.003828897839412093,
- -0.004256919026374817,
- -0.0011422622483223677,
- -0.0010771177476271987,
- -0.00037898647133260965,
- 2.5171791548928013e-06,
- -0.00026067905128002167,
- -0.00014146546891424805,
- 0.0038321535103023052,
- -0.0004293300735298544,
- -0.00142992555629462,
- -0.0009228314156644046,
- 0.0006944393389858305,
- 0.00043302192352712154,
- -0.0035714071709662676,
- -0.0004967569257132709,
- 0.0008057993836700916,
- 0.0005424688570201397,
- -0.0005309234256856143,
- -0.0007159864180721343,
- -0.0010389237431809306,
- -0.0009490771917626262,
- -8.649027586216107e-05,
- 0.0002766547549981624,
- 0.0021084228064864874,
- -0.0001975146442418918,
- -0.0016405630158260465,
- 0.1162627637386322,
- 0.0002507446042727679,
- -0.0014675153652206063,
- -0.00039680811460129917,
- 0.018962211906909943,
- -0.00018764731066767126,
- 0.011170871555805206,
- -0.0013301445869728923,
- -0.0007356539717875421,
- -0.00030253134900704026,
- -0.00014683544577565044,
- -0.00022228369198273867,
- -0.001650598249398172,
- 0.0002927311579696834,
- -0.00143563118763268,
- 0.03084198758006096,
- -0.007432155776768923,
- -0.00028236035723239183,
- 0.006017433945089579,
- -0.011007187888026237,
- -0.001266107545234263,
- 0.0014901700196787715,
- -0.0001800622121663764,
- 0.002944394713267684,
- -0.004211106337606907,
- 0.0029597999528050423,
- 0.002045023487880826,
- 0.0013397098518908024,
- -0.0012190865818411112,
- 0.34349915385246277,
- 0.0005632104002870619,
- -0.0001262281439267099,
- -0.00515326950699091,
- 0.016240738332271576,
- 0.01709030382335186,
- -0.004175194539129734,
- 0.039775289595127106,
- 0.015226684510707855,
- -0.0010229480685666203,
- 0.0008072761120274663,
- -0.004935584031045437,
- -0.002123525831848383,
- -0.014274083077907562,
- 0.0013746818294748664,
- 0.0014838266652077436,
- 0.1302703619003296,
- -0.00033616088330745697,
- 0.0012919505825266242,
- 0.00037177055492065847,
- 0.019514480605721474,
- 0.00022255218937061727,
- 0.124249167740345,
- -0.00040352059295400977,
- -0.007652895525097847,
- 0.0013010123511776328,
- -0.0011253133416175842,
- -0.007449474185705185,
- 0.19224143028259277,
- -0.003275118535384536,
- -0.0005017912480980158,
- -0.001007912098430097,
- 3.091096004936844e-05,
- -0.0008595998515374959,
- 0.012359987013041973,
- -0.0004041247011628002,
- -0.004328910261392593,
- 0.3185553252696991,
- 0.002330605871975422,
- 0.0021182901691645384,
- 0.0001405928487656638,
- 0.2779357433319092,
- 0.005738262087106705,
- 0.0058898297138512135,
- -0.0009689796715974808,
- 0.00912561360746622,
- 0.020675739273428917,
- -0.03700518235564232,
- 0.014263041317462921,
- -0.04828466475009918,
- 0.05834139883518219,
- 0.0006514795240946114,
- 0.26360899209976196,
- 0.0004918567719869316,
- -0.00261044898070395,
- 0.08374208211898804,
- 0.020676210522651672,
- -0.003743582172319293,
- 0.01085072010755539,
- -0.001096583902835846,
- 0.00047430366976186633,
- 0.04818058758974075,
- -0.4799128472805023,
- 0.00018429107149131596,
- 0.011861988343298435,
- 0.06088569387793541,
- 0.0008461413672193885,
- 0.005328264087438583,
- -0.011493473313748837,
- -0.11350836604833603,
- 0.006329597905278206,
- 0.00031669469899497926,
- -0.0011600167490541935,
- -0.022669579833745956,
- 0.004070379305630922,
- 0.0073160636238753796,
- -0.00834545586258173,
- -0.27817651629447937,
- 0.0036344374530017376
- ],
- "yaxis": "y"
- }
- ],
- "layout": {
- "legend": {
- "tracegroupgap": 0
- },
- "template": {
- "data": {
- "bar": [
- {
- "error_x": {
- "color": "#2a3f5f"
- },
- "error_y": {
- "color": "#2a3f5f"
- },
- "marker": {
- "line": {
- "color": "#E5ECF6",
- "width": 0.5
- },
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "bar"
- }
- ],
- "barpolar": [
- {
- "marker": {
- "line": {
- "color": "#E5ECF6",
- "width": 0.5
- },
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "barpolar"
- }
- ],
- "carpet": [
- {
- "aaxis": {
- "endlinecolor": "#2a3f5f",
- "gridcolor": "white",
- "linecolor": "white",
- "minorgridcolor": "white",
- "startlinecolor": "#2a3f5f"
- },
- "baxis": {
- "endlinecolor": "#2a3f5f",
- "gridcolor": "white",
- "linecolor": "white",
- "minorgridcolor": "white",
- "startlinecolor": "#2a3f5f"
- },
- "type": "carpet"
- }
- ],
- "choropleth": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "choropleth"
- }
- ],
- "contour": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "contour"
- }
- ],
- "contourcarpet": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "contourcarpet"
- }
- ],
- "heatmap": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "heatmap"
- }
- ],
- "heatmapgl": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "heatmapgl"
- }
- ],
- "histogram": [
- {
- "marker": {
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "histogram"
- }
- ],
- "histogram2d": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "histogram2d"
- }
- ],
- "histogram2dcontour": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "histogram2dcontour"
- }
- ],
- "mesh3d": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "mesh3d"
- }
- ],
- "parcoords": [
- {
- "line": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "parcoords"
- }
- ],
- "pie": [
- {
- "automargin": true,
- "type": "pie"
- }
- ],
- "scatter": [
- {
- "fillpattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- },
- "type": "scatter"
- }
- ],
- "scatter3d": [
- {
- "line": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatter3d"
- }
- ],
- "scattercarpet": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattercarpet"
- }
- ],
- "scattergeo": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattergeo"
- }
- ],
- "scattergl": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattergl"
- }
- ],
- "scattermapbox": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattermapbox"
- }
- ],
- "scatterpolar": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterpolar"
- }
- ],
- "scatterpolargl": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterpolargl"
- }
- ],
- "scatterternary": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterternary"
- }
- ],
- "surface": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "surface"
- }
- ],
- "table": [
- {
- "cells": {
- "fill": {
- "color": "#EBF0F8"
- },
- "line": {
- "color": "white"
- }
- },
- "header": {
- "fill": {
- "color": "#C8D4E3"
- },
- "line": {
- "color": "white"
- }
- },
- "type": "table"
- }
- ]
- },
- "layout": {
- "annotationdefaults": {
- "arrowcolor": "#2a3f5f",
- "arrowhead": 0,
- "arrowwidth": 1
- },
- "autotypenumbers": "strict",
- "coloraxis": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "colorscale": {
- "diverging": [
- [
- 0,
- "#8e0152"
- ],
- [
- 0.1,
- "#c51b7d"
- ],
- [
- 0.2,
- "#de77ae"
- ],
- [
- 0.3,
- "#f1b6da"
- ],
- [
- 0.4,
- "#fde0ef"
- ],
- [
- 0.5,
- "#f7f7f7"
- ],
- [
- 0.6,
- "#e6f5d0"
- ],
- [
- 0.7,
- "#b8e186"
- ],
- [
- 0.8,
- "#7fbc41"
- ],
- [
- 0.9,
- "#4d9221"
- ],
- [
- 1,
- "#276419"
- ]
- ],
- "sequential": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "sequentialminus": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ]
- },
- "colorway": [
- "#636efa",
- "#EF553B",
- "#00cc96",
- "#ab63fa",
- "#FFA15A",
- "#19d3f3",
- "#FF6692",
- "#B6E880",
- "#FF97FF",
- "#FECB52"
- ],
- "font": {
- "color": "#2a3f5f"
- },
- "geo": {
- "bgcolor": "white",
- "lakecolor": "white",
- "landcolor": "#E5ECF6",
- "showlakes": true,
- "showland": true,
- "subunitcolor": "white"
- },
- "hoverlabel": {
- "align": "left"
- },
- "hovermode": "closest",
- "mapbox": {
- "style": "light"
- },
- "paper_bgcolor": "white",
- "plot_bgcolor": "#E5ECF6",
- "polar": {
- "angularaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "bgcolor": "#E5ECF6",
- "radialaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- }
- },
- "scene": {
- "xaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- },
- "yaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- },
- "zaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- }
- },
- "shapedefaults": {
- "line": {
- "color": "#2a3f5f"
- }
- },
- "ternary": {
- "aaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "baxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "bgcolor": "#E5ECF6",
- "caxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- }
- },
- "title": {
- "x": 0.05
- },
- "xaxis": {
- "automargin": true,
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": "",
- "title": {
- "standoff": 15
- },
- "zerolinecolor": "white",
- "zerolinewidth": 2
- },
- "yaxis": {
- "automargin": true,
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": "",
- "title": {
- "standoff": 15
- },
- "zerolinecolor": "white",
- "zerolinewidth": 2
- }
- }
- },
- "title": {
- "text": "Scatter plot of output patching vs attention patching"
- },
- "xaxis": {
- "anchor": "y",
- "domain": [
- 0,
- 1
- ],
- "title": {
- "text": "Attention Patch"
- }
- },
- "yaxis": {
- "anchor": "x",
- "domain": [
- 0,
- 1
- ],
- "title": {
- "text": "Output Patch"
- }
- }
- }
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"imshow(\n",
" patched_head_attn_diff,\n",
@@ -14101,47 +1417,9 @@
},
{
"cell_type": "code",
- "execution_count": 33,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- ""
- ],
- "text/plain": [
- ""
- ]
- },
- "execution_count": 33,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
"top_k = 10\n",
"top_heads_by_output_patch = torch.topk(\n",
@@ -14239,7 +1517,7 @@
},
{
"cell_type": "code",
- "execution_count": 34,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -14254,31 +1532,9 @@
},
{
"cell_type": "code",
- "execution_count": 35,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- ""
- ],
- "text/plain": [
- ""
- ]
- },
- "execution_count": 35,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
"code = visualize_attention_patterns(\n",
" induction_head_labels,\n",
@@ -14350,25 +1606,9 @@
},
{
"cell_type": "code",
- "execution_count": 36,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "tensor([[0.0390, 0.0000, 0.0310],\n",
- " [0.1890, 0.1720, 0.0680],\n",
- " [0.1570, 0.0210, 0.4820]])\n",
- "tensor([[0.0030, 0.1320, 0.0050],\n",
- " [0.0000, 0.0000, 0.0020],\n",
- " [0.0020, 0.0090, 0.0000]])\n",
- "tensor([[0.0040, 0.0000, 0.0040],\n",
- " [0.0010, 0.0000, 0.0020],\n",
- " [0.0020, 0.0090, 0.0020]])\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"seq_len = 100\n",
"batch_size = 2\n",
@@ -14444,3265 +1684,9 @@
},
{
"cell_type": "code",
- "execution_count": 37,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "application/vnd.plotly.v1+json": {
- "config": {
- "plotlyServerURL": "https://plot.ly"
- },
- "data": [
- {
- "coloraxis": "coloraxis",
- "hovertemplate": "Head: %{x}
Layer: %{y}
color: %{z}",
- "name": "0",
- "type": "heatmap",
- "xaxis": "x",
- "yaxis": "y",
- "z": [
- [
- 0.039069853723049164,
- 0.0004489101702347398,
- 0.03133601322770119,
- 0.007519590202718973,
- 0.034592196345329285,
- 0.00036230171099305153,
- 0.034512776881456375,
- 0.19740213453769684,
- 0.038447845727205276,
- 0.04053792357444763,
- 0.027628764510154724,
- 0.02496313862502575
- ],
- [
- 0.1890650987625122,
- 0.17219914495944977,
- 0.06807752698659897,
- 0.04494515433907509,
- 0.07908554375171661,
- 0.03096739575266838,
- 0.028282109647989273,
- 0.03644327446818352,
- 0.026936717331409454,
- 0.018826229497790337,
- 0.045100897550582886,
- 0.0065726665779948235
- ],
- [
- 0.15745528042316437,
- 0.020724520087242126,
- 0.4817989468574524,
- 0.2991352379322052,
- 0.10764895379543304,
- 0.33004048466682434,
- 0.0997551754117012,
- 0.04926132410764694,
- 0.25493940711021423,
- 0.3606453835964203,
- 0.1257179230451584,
- 0.07931824028491974
- ],
- [
- 0.005844001192599535,
- 0.15787364542484283,
- 0.4189082086086273,
- 0.30129021406173706,
- 0.014345049858093262,
- 0.032344333827495575,
- 0.3312888443470001,
- 0.5285974144935608,
- 0.34242063760757446,
- 0.101837158203125,
- 0.10516070574522018,
- 0.2233113795518875
- ],
- [
- 0.10626544803380966,
- 0.11930850893259048,
- 0.022880680859088898,
- 0.22826944291591644,
- 0.020003994926810265,
- 0.10010036826133728,
- 0.1739213615655899,
- 0.17407020926475525,
- 0.02587701380252838,
- 0.10249985754489899,
- 0.009514841251075268,
- 0.9921423196792603
- ],
- [
- 0.019766658544540405,
- 0.00528325280174613,
- 0.16648508608341217,
- 0.12087740004062653,
- 0.16500000655651093,
- 0.00803269725292921,
- 0.41770195960998535,
- 0.025827765464782715,
- 0.04802601411938667,
- 0.016231779009103775,
- 0.03110172413289547,
- 0.024261215701699257
- ],
- [
- 0.2172909826040268,
- 0.039100028574466705,
- 0.01804858259856701,
- 0.059900715947151184,
- 0.032934583723545074,
- 0.0873451679944992,
- 0.026895340532064438,
- 0.0943947583436966,
- 0.49925994873046875,
- 0.006240115500986576,
- 0.027026718482375145,
- 0.1278565675020218
- ],
- [
- 0.2511657178401947,
- 0.01330868061631918,
- 0.006663354113698006,
- 0.037430502474308014,
- 0.02331537753343582,
- 0.01740722358226776,
- 0.022067422047257423,
- 0.022141192108392715,
- 0.04502448812127113,
- 0.0208425372838974,
- 0.008310739882290363,
- 0.017167754471302032
- ],
- [
- 0.020890623331069946,
- 0.016537941992282867,
- 0.02158307284116745,
- 0.0150058064609766,
- 0.02421221323311329,
- 0.10198988765478134,
- 0.029100384563207626,
- 0.22793792188167572,
- 0.02781485579907894,
- 0.0179410632699728,
- 0.024828944355249405,
- 0.03806235268712044
- ],
- [
- 0.02607586607336998,
- 0.015407431870698929,
- 0.02044427953660488,
- 0.14558182656764984,
- 0.01247025839984417,
- 0.017151640728116035,
- 0.013311829417943954,
- 0.024451706558465958,
- 0.018111787736415863,
- 0.01319331955164671,
- 0.0357399508357048,
- 0.01879822090268135
- ],
- [
- 0.02147812582552433,
- 0.018419174477458,
- 0.018183622509241104,
- 0.02172141708433628,
- 0.0315677747130394,
- 0.034705750644207,
- 0.017550116404891014,
- 0.011417553760111332,
- 0.01579565554857254,
- 0.04592214897274971,
- 0.01621554046869278,
- 0.03039470687508583
- ],
- [
- 0.03320508822798729,
- 0.0175714660435915,
- 0.015131079591810703,
- 0.04148406535387039,
- 0.015181189402937889,
- 0.01758997142314911,
- 0.015148494392633438,
- 0.01767607219517231,
- 0.06622709333896637,
- 0.018451133742928505,
- 0.01700744964182377,
- 0.029749270528554916
- ]
- ]
- }
- ],
- "layout": {
- "coloraxis": {
- "cmid": 0,
- "colorscale": [
- [
- 0,
- "rgb(103,0,31)"
- ],
- [
- 0.1,
- "rgb(178,24,43)"
- ],
- [
- 0.2,
- "rgb(214,96,77)"
- ],
- [
- 0.3,
- "rgb(244,165,130)"
- ],
- [
- 0.4,
- "rgb(253,219,199)"
- ],
- [
- 0.5,
- "rgb(247,247,247)"
- ],
- [
- 0.6,
- "rgb(209,229,240)"
- ],
- [
- 0.7,
- "rgb(146,197,222)"
- ],
- [
- 0.8,
- "rgb(67,147,195)"
- ],
- [
- 0.9,
- "rgb(33,102,172)"
- ],
- [
- 1,
- "rgb(5,48,97)"
- ]
- ]
- },
- "template": {
- "data": {
- "bar": [
- {
- "error_x": {
- "color": "#2a3f5f"
- },
- "error_y": {
- "color": "#2a3f5f"
- },
- "marker": {
- "line": {
- "color": "#E5ECF6",
- "width": 0.5
- },
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "bar"
- }
- ],
- "barpolar": [
- {
- "marker": {
- "line": {
- "color": "#E5ECF6",
- "width": 0.5
- },
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "barpolar"
- }
- ],
- "carpet": [
- {
- "aaxis": {
- "endlinecolor": "#2a3f5f",
- "gridcolor": "white",
- "linecolor": "white",
- "minorgridcolor": "white",
- "startlinecolor": "#2a3f5f"
- },
- "baxis": {
- "endlinecolor": "#2a3f5f",
- "gridcolor": "white",
- "linecolor": "white",
- "minorgridcolor": "white",
- "startlinecolor": "#2a3f5f"
- },
- "type": "carpet"
- }
- ],
- "choropleth": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "choropleth"
- }
- ],
- "contour": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "contour"
- }
- ],
- "contourcarpet": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "contourcarpet"
- }
- ],
- "heatmap": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "heatmap"
- }
- ],
- "heatmapgl": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "heatmapgl"
- }
- ],
- "histogram": [
- {
- "marker": {
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "histogram"
- }
- ],
- "histogram2d": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "histogram2d"
- }
- ],
- "histogram2dcontour": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "histogram2dcontour"
- }
- ],
- "mesh3d": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "mesh3d"
- }
- ],
- "parcoords": [
- {
- "line": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "parcoords"
- }
- ],
- "pie": [
- {
- "automargin": true,
- "type": "pie"
- }
- ],
- "scatter": [
- {
- "fillpattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- },
- "type": "scatter"
- }
- ],
- "scatter3d": [
- {
- "line": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatter3d"
- }
- ],
- "scattercarpet": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattercarpet"
- }
- ],
- "scattergeo": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattergeo"
- }
- ],
- "scattergl": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattergl"
- }
- ],
- "scattermapbox": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattermapbox"
- }
- ],
- "scatterpolar": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterpolar"
- }
- ],
- "scatterpolargl": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterpolargl"
- }
- ],
- "scatterternary": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterternary"
- }
- ],
- "surface": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "surface"
- }
- ],
- "table": [
- {
- "cells": {
- "fill": {
- "color": "#EBF0F8"
- },
- "line": {
- "color": "white"
- }
- },
- "header": {
- "fill": {
- "color": "#C8D4E3"
- },
- "line": {
- "color": "white"
- }
- },
- "type": "table"
- }
- ]
- },
- "layout": {
- "annotationdefaults": {
- "arrowcolor": "#2a3f5f",
- "arrowhead": 0,
- "arrowwidth": 1
- },
- "autotypenumbers": "strict",
- "coloraxis": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "colorscale": {
- "diverging": [
- [
- 0,
- "#8e0152"
- ],
- [
- 0.1,
- "#c51b7d"
- ],
- [
- 0.2,
- "#de77ae"
- ],
- [
- 0.3,
- "#f1b6da"
- ],
- [
- 0.4,
- "#fde0ef"
- ],
- [
- 0.5,
- "#f7f7f7"
- ],
- [
- 0.6,
- "#e6f5d0"
- ],
- [
- 0.7,
- "#b8e186"
- ],
- [
- 0.8,
- "#7fbc41"
- ],
- [
- 0.9,
- "#4d9221"
- ],
- [
- 1,
- "#276419"
- ]
- ],
- "sequential": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "sequentialminus": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ]
- },
- "colorway": [
- "#636efa",
- "#EF553B",
- "#00cc96",
- "#ab63fa",
- "#FFA15A",
- "#19d3f3",
- "#FF6692",
- "#B6E880",
- "#FF97FF",
- "#FECB52"
- ],
- "font": {
- "color": "#2a3f5f"
- },
- "geo": {
- "bgcolor": "white",
- "lakecolor": "white",
- "landcolor": "#E5ECF6",
- "showlakes": true,
- "showland": true,
- "subunitcolor": "white"
- },
- "hoverlabel": {
- "align": "left"
- },
- "hovermode": "closest",
- "mapbox": {
- "style": "light"
- },
- "paper_bgcolor": "white",
- "plot_bgcolor": "#E5ECF6",
- "polar": {
- "angularaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "bgcolor": "#E5ECF6",
- "radialaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- }
- },
- "scene": {
- "xaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- },
- "yaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- },
- "zaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- }
- },
- "shapedefaults": {
- "line": {
- "color": "#2a3f5f"
- }
- },
- "ternary": {
- "aaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "baxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "bgcolor": "#E5ECF6",
- "caxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- }
- },
- "title": {
- "x": 0.05
- },
- "xaxis": {
- "automargin": true,
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": "",
- "title": {
- "standoff": 15
- },
- "zerolinecolor": "white",
- "zerolinewidth": 2
- },
- "yaxis": {
- "automargin": true,
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": "",
- "title": {
- "standoff": 15
- },
- "zerolinecolor": "white",
- "zerolinewidth": 2
- }
- }
- },
- "title": {
- "text": "Previous Token Scores"
- },
- "xaxis": {
- "anchor": "y",
- "constrain": "domain",
- "domain": [
- 0,
- 1
- ],
- "scaleanchor": "y",
- "title": {
- "text": "Head"
- }
- },
- "yaxis": {
- "anchor": "x",
- "autorange": "reversed",
- "constrain": "domain",
- "domain": [
- 0,
- 1
- ],
- "title": {
- "text": "Layer"
- }
- }
- }
- }
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "application/vnd.plotly.v1+json": {
- "config": {
- "plotlyServerURL": "https://plot.ly"
- },
- "data": [
- {
- "coloraxis": "coloraxis",
- "hovertemplate": "Head: %{x}
Layer: %{y}
color: %{z}",
- "name": "0",
- "type": "heatmap",
- "xaxis": "x",
- "yaxis": "y",
- "z": [
- [
- 0.0031923248898237944,
- 0.13236315548419952,
- 0.005006915424019098,
- 1.0427449524286203e-05,
- 0.0013110184809193015,
- 0.7034568786621094,
- 0.00426204688847065,
- 0.00016496369789820164,
- 0.002474633976817131,
- 0.0008572910446673632,
- 0.01889149099588394,
- 0.008690938353538513
- ],
- [
- 0.0002916341181844473,
- 0.00013782267342321575,
- 0.0015036173863336444,
- 0.005392482969909906,
- 0.0018583914497867227,
- 0.009062949568033218,
- 0.012414448894560337,
- 0.0022405502386391163,
- 0.005135662388056517,
- 0.005220627877861261,
- 0.005546474829316139,
- 0.02975049614906311
- ],
- [
- 0.0024816279765218496,
- 0.009442180395126343,
- 0.0003456332196947187,
- 0.0002591445227153599,
- 0.0052116685546934605,
- 0.000570951378904283,
- 0.0015209749108180404,
- 0.006313100922852755,
- 0.001560864970088005,
- 0.0004215767839923501,
- 0.00015359291865024716,
- 0.005160381551831961
- ],
- [
- 0.6775657534599304,
- 0.002840448170900345,
- 0.0007841526530683041,
- 0.00471264636144042,
- 0.006322895642369986,
- 0.006206681486219168,
- 0.0005474805948324502,
- 0.00037829449865967035,
- 0.0020155368838459253,
- 0.007952751591801643,
- 0.003576782764866948,
- 0.002608788898214698
- ],
- [
- 0.00860405620187521,
- 0.0070286463014781475,
- 0.007598803844302893,
- 0.003442801535129547,
- 0.016561277210712433,
- 0.0059797209687530994,
- 0.004869826138019562,
- 0.0007624455611221492,
- 0.006062133703380823,
- 0.007536627352237701,
- 0.012022900395095348,
- 1.055422134237094e-12
- ],
- [
- 0.00950299296528101,
- 0.00856209360063076,
- 0.004162600729614496,
- 0.003008665982633829,
- 0.006847422569990158,
- 0.004358117934316397,
- 0.007669268175959587,
- 0.009584215469658375,
- 0.0076188258826732635,
- 0.0043280418030917645,
- 0.041402824223041534,
- 0.00976183544844389
- ],
- [
- 0.004456141032278538,
- 0.008873268961906433,
- 0.007405205629765987,
- 0.0062249391339719296,
- 0.00731915095821023,
- 0.005623893812298775,
- 0.017349667847156525,
- 0.005529467947781086,
- 0.002920132130384445,
- 0.008636755868792534,
- 0.006222263444215059,
- 0.00835894700139761
- ],
- [
- 0.003699858672916889,
- 0.04107949137687683,
- 0.04148268699645996,
- 0.009313640184700489,
- 0.009097025729715824,
- 0.008774377405643463,
- 0.007298537530004978,
- 0.023312218487262726,
- 0.008843323215842247,
- 0.00987986009567976,
- 0.017598601058125496,
- 0.006039854139089584
- ],
- [
- 0.008986304514110088,
- 0.028667239472270012,
- 0.008891218341886997,
- 0.010114557109773159,
- 0.009737391024827957,
- 0.007611637003719807,
- 0.009763265959918499,
- 0.005155472084879875,
- 0.009276345372200012,
- 0.011895839124917984,
- 0.010411946102976799,
- 0.007498950231820345
- ],
- [
- 0.024409977719187737,
- 0.011438451707363129,
- 0.02003096230328083,
- 0.0051185814663767815,
- 0.015081286430358887,
- 0.012334450148046017,
- 0.015452565625309944,
- 0.008602450601756573,
- 0.014702522195875645,
- 0.020766200497746468,
- 0.009192758239805698,
- 0.005703347735106945
- ],
- [
- 0.017897022888064384,
- 0.013280633836984634,
- 0.006755237001925707,
- 0.012744844891130924,
- 0.008020960725843906,
- 0.007722244597971439,
- 0.017341373488307,
- 0.0074546560645103455,
- 0.007832515984773636,
- 0.00825214572250843,
- 0.013642766512930393,
- 0.012807483784854412
- ],
- [
- 0.004923742264509201,
- 0.007951060310006142,
- 0.007947920821607113,
- 0.004564082249999046,
- 0.010363400913774967,
- 0.009582078084349632,
- 0.0102877551689744,
- 0.00832072552293539,
- 0.0025700009427964687,
- 0.012810997664928436,
- 0.008063871413469315,
- 0.006558285094797611
- ]
- ]
- }
- ],
- "layout": {
- "coloraxis": {
- "cmid": 0,
- "colorscale": [
- [
- 0,
- "rgb(103,0,31)"
- ],
- [
- 0.1,
- "rgb(178,24,43)"
- ],
- [
- 0.2,
- "rgb(214,96,77)"
- ],
- [
- 0.3,
- "rgb(244,165,130)"
- ],
- [
- 0.4,
- "rgb(253,219,199)"
- ],
- [
- 0.5,
- "rgb(247,247,247)"
- ],
- [
- 0.6,
- "rgb(209,229,240)"
- ],
- [
- 0.7,
- "rgb(146,197,222)"
- ],
- [
- 0.8,
- "rgb(67,147,195)"
- ],
- [
- 0.9,
- "rgb(33,102,172)"
- ],
- [
- 1,
- "rgb(5,48,97)"
- ]
- ]
- },
- "template": {
- "data": {
- "bar": [
- {
- "error_x": {
- "color": "#2a3f5f"
- },
- "error_y": {
- "color": "#2a3f5f"
- },
- "marker": {
- "line": {
- "color": "#E5ECF6",
- "width": 0.5
- },
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "bar"
- }
- ],
- "barpolar": [
- {
- "marker": {
- "line": {
- "color": "#E5ECF6",
- "width": 0.5
- },
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "barpolar"
- }
- ],
- "carpet": [
- {
- "aaxis": {
- "endlinecolor": "#2a3f5f",
- "gridcolor": "white",
- "linecolor": "white",
- "minorgridcolor": "white",
- "startlinecolor": "#2a3f5f"
- },
- "baxis": {
- "endlinecolor": "#2a3f5f",
- "gridcolor": "white",
- "linecolor": "white",
- "minorgridcolor": "white",
- "startlinecolor": "#2a3f5f"
- },
- "type": "carpet"
- }
- ],
- "choropleth": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "choropleth"
- }
- ],
- "contour": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "contour"
- }
- ],
- "contourcarpet": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "contourcarpet"
- }
- ],
- "heatmap": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "heatmap"
- }
- ],
- "heatmapgl": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "heatmapgl"
- }
- ],
- "histogram": [
- {
- "marker": {
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "histogram"
- }
- ],
- "histogram2d": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "histogram2d"
- }
- ],
- "histogram2dcontour": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "histogram2dcontour"
- }
- ],
- "mesh3d": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "mesh3d"
- }
- ],
- "parcoords": [
- {
- "line": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "parcoords"
- }
- ],
- "pie": [
- {
- "automargin": true,
- "type": "pie"
- }
- ],
- "scatter": [
- {
- "fillpattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- },
- "type": "scatter"
- }
- ],
- "scatter3d": [
- {
- "line": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatter3d"
- }
- ],
- "scattercarpet": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattercarpet"
- }
- ],
- "scattergeo": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattergeo"
- }
- ],
- "scattergl": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattergl"
- }
- ],
- "scattermapbox": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattermapbox"
- }
- ],
- "scatterpolar": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterpolar"
- }
- ],
- "scatterpolargl": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterpolargl"
- }
- ],
- "scatterternary": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterternary"
- }
- ],
- "surface": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "surface"
- }
- ],
- "table": [
- {
- "cells": {
- "fill": {
- "color": "#EBF0F8"
- },
- "line": {
- "color": "white"
- }
- },
- "header": {
- "fill": {
- "color": "#C8D4E3"
- },
- "line": {
- "color": "white"
- }
- },
- "type": "table"
- }
- ]
- },
- "layout": {
- "annotationdefaults": {
- "arrowcolor": "#2a3f5f",
- "arrowhead": 0,
- "arrowwidth": 1
- },
- "autotypenumbers": "strict",
- "coloraxis": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "colorscale": {
- "diverging": [
- [
- 0,
- "#8e0152"
- ],
- [
- 0.1,
- "#c51b7d"
- ],
- [
- 0.2,
- "#de77ae"
- ],
- [
- 0.3,
- "#f1b6da"
- ],
- [
- 0.4,
- "#fde0ef"
- ],
- [
- 0.5,
- "#f7f7f7"
- ],
- [
- 0.6,
- "#e6f5d0"
- ],
- [
- 0.7,
- "#b8e186"
- ],
- [
- 0.8,
- "#7fbc41"
- ],
- [
- 0.9,
- "#4d9221"
- ],
- [
- 1,
- "#276419"
- ]
- ],
- "sequential": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "sequentialminus": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ]
- },
- "colorway": [
- "#636efa",
- "#EF553B",
- "#00cc96",
- "#ab63fa",
- "#FFA15A",
- "#19d3f3",
- "#FF6692",
- "#B6E880",
- "#FF97FF",
- "#FECB52"
- ],
- "font": {
- "color": "#2a3f5f"
- },
- "geo": {
- "bgcolor": "white",
- "lakecolor": "white",
- "landcolor": "#E5ECF6",
- "showlakes": true,
- "showland": true,
- "subunitcolor": "white"
- },
- "hoverlabel": {
- "align": "left"
- },
- "hovermode": "closest",
- "mapbox": {
- "style": "light"
- },
- "paper_bgcolor": "white",
- "plot_bgcolor": "#E5ECF6",
- "polar": {
- "angularaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "bgcolor": "#E5ECF6",
- "radialaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- }
- },
- "scene": {
- "xaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- },
- "yaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- },
- "zaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- }
- },
- "shapedefaults": {
- "line": {
- "color": "#2a3f5f"
- }
- },
- "ternary": {
- "aaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "baxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "bgcolor": "#E5ECF6",
- "caxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- }
- },
- "title": {
- "x": 0.05
- },
- "xaxis": {
- "automargin": true,
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": "",
- "title": {
- "standoff": 15
- },
- "zerolinecolor": "white",
- "zerolinewidth": 2
- },
- "yaxis": {
- "automargin": true,
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": "",
- "title": {
- "standoff": 15
- },
- "zerolinecolor": "white",
- "zerolinewidth": 2
- }
- }
- },
- "title": {
- "text": "Duplicate Token Scores"
- },
- "xaxis": {
- "anchor": "y",
- "constrain": "domain",
- "domain": [
- 0,
- 1
- ],
- "scaleanchor": "y",
- "title": {
- "text": "Head"
- }
- },
- "yaxis": {
- "anchor": "x",
- "autorange": "reversed",
- "constrain": "domain",
- "domain": [
- 0,
- 1
- ],
- "title": {
- "text": "Layer"
- }
- }
- }
- }
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "application/vnd.plotly.v1+json": {
- "config": {
- "plotlyServerURL": "https://plot.ly"
- },
- "data": [
- {
- "coloraxis": "coloraxis",
- "hovertemplate": "Head: %{x}
Layer: %{y}
color: %{z}",
- "name": "0",
- "type": "heatmap",
- "xaxis": "x",
- "yaxis": "y",
- "z": [
- [
- 0.004035575315356255,
- 3.85937346436549e-05,
- 0.003946058917790651,
- 1.7428524756724073e-07,
- 5.9896130551351234e-05,
- 4.0836803236743435e-05,
- 0.0035017586778849363,
- 0.00024610417312942445,
- 0.0031679815147072077,
- 0.0030104012694209814,
- 0.002093541668727994,
- 0.008525434881448746
- ],
- [
- 0.000526473973877728,
- 0.00015670718858018517,
- 0.001507942914031446,
- 0.005595325026661158,
- 0.0018401180859655142,
- 0.0038875630125403404,
- 0.005349153187125921,
- 0.004649169277399778,
- 0.005880181211978197,
- 0.007283917628228664,
- 0.005552186165004969,
- 0.00012677280756179243
- ],
- [
- 0.0022015420254319906,
- 0.008784863166511059,
- 0.002159146359190345,
- 0.0010447809472680092,
- 0.005142326466739178,
- 0.002251626690849662,
- 0.0008376616751775146,
- 0.006352409720420837,
- 0.002618127502501011,
- 0.0010309136705473065,
- 0.00015219187480397522,
- 0.005351166240870953
- ],
- [
- 0.007752244360744953,
- 0.0030915802344679832,
- 0.001362923881970346,
- 0.004341960418969393,
- 0.011233060620725155,
- 0.006535551976412535,
- 0.000906877510715276,
- 0.0006078600417822599,
- 0.002819513902068138,
- 0.005254077725112438,
- 0.004195652436465025,
- 0.00255418848246336
- ],
- [
- 0.007342735771089792,
- 0.004788339603692293,
- 0.007458819076418877,
- 0.0033073313534259796,
- 0.007871866226196289,
- 0.004219769034534693,
- 0.004172054585069418,
- 0.0005154653917998075,
- 0.008124975487589836,
- 0.0068268910981714725,
- 0.008085492067039013,
- 3.761376626831847e-11
- ],
- [
- 0.4337766170501709,
- 0.9306095838546753,
- 0.006382268853485584,
- 0.0034730439074337482,
- 0.005500996019691229,
- 0.9255973696708679,
- 0.00538142304867506,
- 0.007857315242290497,
- 0.00863779615610838,
- 0.01576443389058113,
- 0.012188379652798176,
- 0.008265726268291473
- ],
- [
- 0.002507298020645976,
- 0.008432027883827686,
- 0.008623305708169937,
- 0.007653353735804558,
- 0.01105806790292263,
- 0.005525435321033001,
- 0.017205175012350082,
- 0.004794349893927574,
- 0.0040976013988256454,
- 0.9257788062095642,
- 0.020375633612275124,
- 0.006313954945653677
- ],
- [
- 0.005555536597967148,
- 0.18942977488040924,
- 0.8509925007820129,
- 0.008273146115243435,
- 0.008239664137363434,
- 0.00864996388554573,
- 0.02832852303981781,
- 0.08996275067329407,
- 0.006617339327931404,
- 0.009413909167051315,
- 0.9037814736366272,
- 0.03037159889936447
- ],
- [
- 0.00735454261302948,
- 0.3791317641735077,
- 0.005602709017693996,
- 0.025401461869478226,
- 0.008504674769937992,
- 0.00623108958825469,
- 0.11892436444759369,
- 0.005114651285111904,
- 0.013350939378142357,
- 0.01576736941933632,
- 0.025843923911452293,
- 0.008429747074842453
- ],
- [
- 0.2398916333913803,
- 0.14378757774829865,
- 0.09330663084983826,
- 0.005819779820740223,
- 0.07744801044464111,
- 0.01644793339073658,
- 0.4442836344242096,
- 0.011141352355480194,
- 0.03619001433253288,
- 0.472646564245224,
- 0.00803996529430151,
- 0.030953049659729004
- ],
- [
- 0.3606555163860321,
- 0.48201146721839905,
- 0.022851115092635155,
- 0.1264195442199707,
- 0.04125598818063736,
- 0.0072374604642391205,
- 0.2877156138420105,
- 0.3897320628166199,
- 0.030060900375247,
- 0.006112942937761545,
- 0.1655488908290863,
- 0.22245149314403534
- ],
- [
- 0.007408542558550835,
- 0.033737149089574814,
- 0.02041277289390564,
- 0.002755412133410573,
- 0.02518630214035511,
- 0.07808877527713776,
- 0.033082809299230576,
- 0.046440087258815765,
- 0.0032543439883738756,
- 0.2744256258010864,
- 0.3800230026245117,
- 0.009483495727181435
- ]
- ]
- }
- ],
- "layout": {
- "coloraxis": {
- "cmid": 0,
- "colorscale": [
- [
- 0,
- "rgb(103,0,31)"
- ],
- [
- 0.1,
- "rgb(178,24,43)"
- ],
- [
- 0.2,
- "rgb(214,96,77)"
- ],
- [
- 0.3,
- "rgb(244,165,130)"
- ],
- [
- 0.4,
- "rgb(253,219,199)"
- ],
- [
- 0.5,
- "rgb(247,247,247)"
- ],
- [
- 0.6,
- "rgb(209,229,240)"
- ],
- [
- 0.7,
- "rgb(146,197,222)"
- ],
- [
- 0.8,
- "rgb(67,147,195)"
- ],
- [
- 0.9,
- "rgb(33,102,172)"
- ],
- [
- 1,
- "rgb(5,48,97)"
- ]
- ]
- },
- "template": {
- "data": {
- "bar": [
- {
- "error_x": {
- "color": "#2a3f5f"
- },
- "error_y": {
- "color": "#2a3f5f"
- },
- "marker": {
- "line": {
- "color": "#E5ECF6",
- "width": 0.5
- },
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "bar"
- }
- ],
- "barpolar": [
- {
- "marker": {
- "line": {
- "color": "#E5ECF6",
- "width": 0.5
- },
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "barpolar"
- }
- ],
- "carpet": [
- {
- "aaxis": {
- "endlinecolor": "#2a3f5f",
- "gridcolor": "white",
- "linecolor": "white",
- "minorgridcolor": "white",
- "startlinecolor": "#2a3f5f"
- },
- "baxis": {
- "endlinecolor": "#2a3f5f",
- "gridcolor": "white",
- "linecolor": "white",
- "minorgridcolor": "white",
- "startlinecolor": "#2a3f5f"
- },
- "type": "carpet"
- }
- ],
- "choropleth": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "choropleth"
- }
- ],
- "contour": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "contour"
- }
- ],
- "contourcarpet": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "contourcarpet"
- }
- ],
- "heatmap": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "heatmap"
- }
- ],
- "heatmapgl": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "heatmapgl"
- }
- ],
- "histogram": [
- {
- "marker": {
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "histogram"
- }
- ],
- "histogram2d": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "histogram2d"
- }
- ],
- "histogram2dcontour": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "histogram2dcontour"
- }
- ],
- "mesh3d": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "mesh3d"
- }
- ],
- "parcoords": [
- {
- "line": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "parcoords"
- }
- ],
- "pie": [
- {
- "automargin": true,
- "type": "pie"
- }
- ],
- "scatter": [
- {
- "fillpattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- },
- "type": "scatter"
- }
- ],
- "scatter3d": [
- {
- "line": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatter3d"
- }
- ],
- "scattercarpet": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattercarpet"
- }
- ],
- "scattergeo": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattergeo"
- }
- ],
- "scattergl": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattergl"
- }
- ],
- "scattermapbox": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattermapbox"
- }
- ],
- "scatterpolar": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterpolar"
- }
- ],
- "scatterpolargl": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterpolargl"
- }
- ],
- "scatterternary": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterternary"
- }
- ],
- "surface": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "surface"
- }
- ],
- "table": [
- {
- "cells": {
- "fill": {
- "color": "#EBF0F8"
- },
- "line": {
- "color": "white"
- }
- },
- "header": {
- "fill": {
- "color": "#C8D4E3"
- },
- "line": {
- "color": "white"
- }
- },
- "type": "table"
- }
- ]
- },
- "layout": {
- "annotationdefaults": {
- "arrowcolor": "#2a3f5f",
- "arrowhead": 0,
- "arrowwidth": 1
- },
- "autotypenumbers": "strict",
- "coloraxis": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "colorscale": {
- "diverging": [
- [
- 0,
- "#8e0152"
- ],
- [
- 0.1,
- "#c51b7d"
- ],
- [
- 0.2,
- "#de77ae"
- ],
- [
- 0.3,
- "#f1b6da"
- ],
- [
- 0.4,
- "#fde0ef"
- ],
- [
- 0.5,
- "#f7f7f7"
- ],
- [
- 0.6,
- "#e6f5d0"
- ],
- [
- 0.7,
- "#b8e186"
- ],
- [
- 0.8,
- "#7fbc41"
- ],
- [
- 0.9,
- "#4d9221"
- ],
- [
- 1,
- "#276419"
- ]
- ],
- "sequential": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "sequentialminus": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ]
- },
- "colorway": [
- "#636efa",
- "#EF553B",
- "#00cc96",
- "#ab63fa",
- "#FFA15A",
- "#19d3f3",
- "#FF6692",
- "#B6E880",
- "#FF97FF",
- "#FECB52"
- ],
- "font": {
- "color": "#2a3f5f"
- },
- "geo": {
- "bgcolor": "white",
- "lakecolor": "white",
- "landcolor": "#E5ECF6",
- "showlakes": true,
- "showland": true,
- "subunitcolor": "white"
- },
- "hoverlabel": {
- "align": "left"
- },
- "hovermode": "closest",
- "mapbox": {
- "style": "light"
- },
- "paper_bgcolor": "white",
- "plot_bgcolor": "#E5ECF6",
- "polar": {
- "angularaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "bgcolor": "#E5ECF6",
- "radialaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- }
- },
- "scene": {
- "xaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- },
- "yaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- },
- "zaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- }
- },
- "shapedefaults": {
- "line": {
- "color": "#2a3f5f"
- }
- },
- "ternary": {
- "aaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "baxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "bgcolor": "#E5ECF6",
- "caxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- }
- },
- "title": {
- "x": 0.05
- },
- "xaxis": {
- "automargin": true,
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": "",
- "title": {
- "standoff": 15
- },
- "zerolinecolor": "white",
- "zerolinewidth": 2
- },
- "yaxis": {
- "automargin": true,
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": "",
- "title": {
- "standoff": 15
- },
- "zerolinecolor": "white",
- "zerolinewidth": 2
- }
- }
- },
- "title": {
- "text": "Induction Head Scores"
- },
- "xaxis": {
- "anchor": "y",
- "constrain": "domain",
- "domain": [
- 0,
- 1
- ],
- "scaleanchor": "y",
- "title": {
- "text": "Head"
- }
- },
- "yaxis": {
- "anchor": "x",
- "autorange": "reversed",
- "constrain": "domain",
- "domain": [
- 0,
- 1
- ],
- "title": {
- "text": "Layer"
- }
- }
- }
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"imshow(\n",
" prev_token_scores, labels={\"x\": \"Head\", \"y\": \"Layer\"}, title=\"Previous Token Scores\"\n",
@@ -17763,21 +1747,9 @@
},
{
"cell_type": "code",
- "execution_count": 38,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Top Name Mover to ablate: L9H9\n",
- "Original logit diff: 3.55\n",
- "Post ablation logit diff: 2.92\n",
- "Direct Logit Attribution of top name mover head: 2.99\n",
- "Naive prediction of post ablation logit diff: 0.57\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"top_name_mover = per_head_logit_diffs.flatten().argmax().item()\n",
"top_name_mover_layer = top_name_mover // model.cfg.n_heads\n",
@@ -17786,6 +1758,7 @@
"\n",
"\n",
"def ablate_top_head_hook(z: Float[torch.Tensor, \"batch pos head_index d_head\"], hook):\n",
+ " z = z.clone()\n",
" z[:, -1, top_name_mover_head, :] = 0\n",
" return z\n",
"\n",
@@ -17818,2420 +1791,9 @@
},
{
"cell_type": "code",
- "execution_count": 39,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Tried to stack head results when they weren't cached. Computing head results now\n"
- ]
- },
- {
- "data": {
- "application/vnd.plotly.v1+json": {
- "config": {
- "plotlyServerURL": "https://plot.ly"
- },
- "data": [
- {
- "coloraxis": "coloraxis",
- "hovertemplate": "Head: %{x}
Layer: %{y}
color: %{z}",
- "name": "0",
- "type": "heatmap",
- "xaxis": "x",
- "yaxis": "y",
- "z": [
- [
- -0.002156503964215517,
- -0.0004650682385545224,
- 0.00024167183437384665,
- 0.0002806585980579257,
- -0.0004162999684922397,
- -0.0004892416181974113,
- -0.002620948012918234,
- -0.002935677068307996,
- 0.00042561208829283714,
- 0.0005418329383246601,
- 0.00023754138965159655,
- -7.48957390896976e-05
- ],
- [
- -0.000658505829051137,
- 0.0004060641804244369,
- -0.0009330413886345923,
- 0.0008937822422012687,
- -0.0009785268921405077,
- -0.000533820129930973,
- -0.0027988189831376076,
- -0.004214101936668158,
- 0.002578593324869871,
- 0.0024506838526576757,
- 0.0005351756699383259,
- 0.0012349633034318686
- ],
- [
- 0.0009405204327777028,
- -0.0011168691562488675,
- -0.0011541967978700995,
- -0.0015697095077484846,
- -0.0005699327448382974,
- 0.001451514894142747,
- 0.002439911477267742,
- 0.003158293664455414,
- 0.000923738582059741,
- -0.003578126197680831,
- -0.0010650777257978916,
- -0.0003558753523975611
- ],
- [
- -0.0005624951445497572,
- -1.1960582924075425e-05,
- 0.0011531109921634197,
- 0.0007360265008173883,
- 0.0016493839211761951,
- 0.0008800819050520658,
- -0.0006905529880896211,
- -0.003031972097232938,
- 0.0008080147090367973,
- 0.00010368914809077978,
- -0.0005807994166389108,
- -0.0011067037703469396
- ],
- [
- -0.0026375530287623405,
- 0.0002691895351745188,
- -0.0016417437000200152,
- -0.003406986128538847,
- 0.0017449699807912111,
- 0.00046454701805487275,
- -0.0007899806369096041,
- 0.0018328562146052718,
- -0.00086324627045542,
- -0.0003978293389081955,
- 0.0007879206677898765,
- -0.00012048585631418973
- ],
- [
- 0.0008688560919836164,
- 0.0009473530226387084,
- -0.0022812988609075546,
- -0.0011803123634308577,
- 0.0002407809515716508,
- -0.0004318578285165131,
- -0.0003728170122485608,
- -0.000738416681997478,
- 0.0008113418589346111,
- -0.00040444196201860905,
- -0.007074396125972271,
- 0.003946478478610516
- ],
- [
- -0.014917617663741112,
- -0.0022801742888987064,
- 0.0022679336834698915,
- -8.302251808345318e-05,
- -0.004980948753654957,
- 0.0027670026756823063,
- 0.006266288459300995,
- -0.003485947148874402,
- -0.0013348984066396952,
- -0.0017918883822858334,
- -0.0012231896398589015,
- 0.00040514359716326
- ],
- [
- -0.0002460568503011018,
- -0.005790225230157375,
- -0.0004975841729901731,
- 0.142182856798172,
- -0.0014961492270231247,
- -0.019006317481398582,
- 0.003133433870971203,
- -0.001858205534517765,
- -0.011305196210741997,
- 0.1922595500946045,
- -0.0011892566690221429,
- -0.0010282933944836259
- ],
- [
- -0.0038003993686288595,
- -0.0008570950012654066,
- -0.013956742361187935,
- 0.00828910805284977,
- 0.004315475933253765,
- -0.009073829278349876,
- -0.08315148949623108,
- 0.0034569751005619764,
- -0.01805492490530014,
- 0.002178061753511429,
- 0.29780513048171997,
- 0.02409379370510578
- ],
- [
- 0.08904723823070526,
- -0.0007931794971227646,
- 0.07247699797153473,
- 0.015016308054327965,
- -0.02120928093791008,
- 0.05205465108156204,
- 1.4411165714263916,
- 0.04743674397468567,
- -0.03229031339287758,
- 0,
- 0.0019993737805634737,
- -0.00807223655283451
- ],
- [
- 0.8600788116455078,
- 0.3260062038898468,
- 0.16344408690929413,
- 0.07133537530899048,
- -0.00444837287068367,
- 0.000681330740917474,
- 0.36613449454307556,
- -0.7105098962783813,
- -0.002031375654041767,
- -0.032143525779247284,
- 1.2294330596923828,
- 0.0018453558441251516
- ],
- [
- 0.016877274960279465,
- -0.001730365096591413,
- -0.5010868310928345,
- 0.02749764919281006,
- -0.0059662917628884315,
- -0.004944110754877329,
- -0.08855228126049042,
- 0.006622308399528265,
- 0.044124361127614975,
- -0.02726735547184944,
- -1.134916067123413,
- 0.02287953346967697
- ]
- ]
- }
- ],
- "layout": {
- "coloraxis": {
- "cmid": 0,
- "colorscale": [
- [
- 0,
- "rgb(103,0,31)"
- ],
- [
- 0.1,
- "rgb(178,24,43)"
- ],
- [
- 0.2,
- "rgb(214,96,77)"
- ],
- [
- 0.3,
- "rgb(244,165,130)"
- ],
- [
- 0.4,
- "rgb(253,219,199)"
- ],
- [
- 0.5,
- "rgb(247,247,247)"
- ],
- [
- 0.6,
- "rgb(209,229,240)"
- ],
- [
- 0.7,
- "rgb(146,197,222)"
- ],
- [
- 0.8,
- "rgb(67,147,195)"
- ],
- [
- 0.9,
- "rgb(33,102,172)"
- ],
- [
- 1,
- "rgb(5,48,97)"
- ]
- ]
- },
- "margin": {
- "t": 60
- },
- "template": {
- "data": {
- "bar": [
- {
- "error_x": {
- "color": "#2a3f5f"
- },
- "error_y": {
- "color": "#2a3f5f"
- },
- "marker": {
- "line": {
- "color": "#E5ECF6",
- "width": 0.5
- },
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "bar"
- }
- ],
- "barpolar": [
- {
- "marker": {
- "line": {
- "color": "#E5ECF6",
- "width": 0.5
- },
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "barpolar"
- }
- ],
- "carpet": [
- {
- "aaxis": {
- "endlinecolor": "#2a3f5f",
- "gridcolor": "white",
- "linecolor": "white",
- "minorgridcolor": "white",
- "startlinecolor": "#2a3f5f"
- },
- "baxis": {
- "endlinecolor": "#2a3f5f",
- "gridcolor": "white",
- "linecolor": "white",
- "minorgridcolor": "white",
- "startlinecolor": "#2a3f5f"
- },
- "type": "carpet"
- }
- ],
- "choropleth": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "choropleth"
- }
- ],
- "contour": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "contour"
- }
- ],
- "contourcarpet": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "contourcarpet"
- }
- ],
- "heatmap": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "heatmap"
- }
- ],
- "heatmapgl": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "heatmapgl"
- }
- ],
- "histogram": [
- {
- "marker": {
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "histogram"
- }
- ],
- "histogram2d": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "histogram2d"
- }
- ],
- "histogram2dcontour": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "histogram2dcontour"
- }
- ],
- "mesh3d": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "mesh3d"
- }
- ],
- "parcoords": [
- {
- "line": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "parcoords"
- }
- ],
- "pie": [
- {
- "automargin": true,
- "type": "pie"
- }
- ],
- "scatter": [
- {
- "fillpattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- },
- "type": "scatter"
- }
- ],
- "scatter3d": [
- {
- "line": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatter3d"
- }
- ],
- "scattercarpet": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattercarpet"
- }
- ],
- "scattergeo": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattergeo"
- }
- ],
- "scattergl": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattergl"
- }
- ],
- "scattermapbox": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattermapbox"
- }
- ],
- "scatterpolar": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterpolar"
- }
- ],
- "scatterpolargl": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterpolargl"
- }
- ],
- "scatterternary": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterternary"
- }
- ],
- "surface": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "surface"
- }
- ],
- "table": [
- {
- "cells": {
- "fill": {
- "color": "#EBF0F8"
- },
- "line": {
- "color": "white"
- }
- },
- "header": {
- "fill": {
- "color": "#C8D4E3"
- },
- "line": {
- "color": "white"
- }
- },
- "type": "table"
- }
- ]
- },
- "layout": {
- "annotationdefaults": {
- "arrowcolor": "#2a3f5f",
- "arrowhead": 0,
- "arrowwidth": 1
- },
- "autotypenumbers": "strict",
- "coloraxis": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "colorscale": {
- "diverging": [
- [
- 0,
- "#8e0152"
- ],
- [
- 0.1,
- "#c51b7d"
- ],
- [
- 0.2,
- "#de77ae"
- ],
- [
- 0.3,
- "#f1b6da"
- ],
- [
- 0.4,
- "#fde0ef"
- ],
- [
- 0.5,
- "#f7f7f7"
- ],
- [
- 0.6,
- "#e6f5d0"
- ],
- [
- 0.7,
- "#b8e186"
- ],
- [
- 0.8,
- "#7fbc41"
- ],
- [
- 0.9,
- "#4d9221"
- ],
- [
- 1,
- "#276419"
- ]
- ],
- "sequential": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "sequentialminus": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ]
- },
- "colorway": [
- "#636efa",
- "#EF553B",
- "#00cc96",
- "#ab63fa",
- "#FFA15A",
- "#19d3f3",
- "#FF6692",
- "#B6E880",
- "#FF97FF",
- "#FECB52"
- ],
- "font": {
- "color": "#2a3f5f"
- },
- "geo": {
- "bgcolor": "white",
- "lakecolor": "white",
- "landcolor": "#E5ECF6",
- "showlakes": true,
- "showland": true,
- "subunitcolor": "white"
- },
- "hoverlabel": {
- "align": "left"
- },
- "hovermode": "closest",
- "mapbox": {
- "style": "light"
- },
- "paper_bgcolor": "white",
- "plot_bgcolor": "#E5ECF6",
- "polar": {
- "angularaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "bgcolor": "#E5ECF6",
- "radialaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- }
- },
- "scene": {
- "xaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- },
- "yaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- },
- "zaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- }
- },
- "shapedefaults": {
- "line": {
- "color": "#2a3f5f"
- }
- },
- "ternary": {
- "aaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "baxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "bgcolor": "#E5ECF6",
- "caxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- }
- },
- "title": {
- "x": 0.05
- },
- "xaxis": {
- "automargin": true,
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": "",
- "title": {
- "standoff": 15
- },
- "zerolinecolor": "white",
- "zerolinewidth": 2
- },
- "yaxis": {
- "automargin": true,
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": "",
- "title": {
- "standoff": 15
- },
- "zerolinecolor": "white",
- "zerolinewidth": 2
- }
- }
- },
- "xaxis": {
- "anchor": "y",
- "constrain": "domain",
- "domain": [
- 0,
- 1
- ],
- "scaleanchor": "y",
- "title": {
- "text": "Head"
- }
- },
- "yaxis": {
- "anchor": "x",
- "autorange": "reversed",
- "constrain": "domain",
- "domain": [
- 0,
- 1
- ],
- "title": {
- "text": "Layer"
- }
- }
- }
- }
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "application/vnd.plotly.v1+json": {
- "config": {
- "plotlyServerURL": "https://plot.ly"
- },
- "data": [
- {
- "hovertemplate": "%{hovertext}
Ablated=%{x}
Original=%{y}",
- "hovertext": [
- "L0H0",
- "L0H1",
- "L0H2",
- "L0H3",
- "L0H4",
- "L0H5",
- "L0H6",
- "L0H7",
- "L0H8",
- "L0H9",
- "L0H10",
- "L0H11",
- "L1H0",
- "L1H1",
- "L1H2",
- "L1H3",
- "L1H4",
- "L1H5",
- "L1H6",
- "L1H7",
- "L1H8",
- "L1H9",
- "L1H10",
- "L1H11",
- "L2H0",
- "L2H1",
- "L2H2",
- "L2H3",
- "L2H4",
- "L2H5",
- "L2H6",
- "L2H7",
- "L2H8",
- "L2H9",
- "L2H10",
- "L2H11",
- "L3H0",
- "L3H1",
- "L3H2",
- "L3H3",
- "L3H4",
- "L3H5",
- "L3H6",
- "L3H7",
- "L3H8",
- "L3H9",
- "L3H10",
- "L3H11",
- "L4H0",
- "L4H1",
- "L4H2",
- "L4H3",
- "L4H4",
- "L4H5",
- "L4H6",
- "L4H7",
- "L4H8",
- "L4H9",
- "L4H10",
- "L4H11",
- "L5H0",
- "L5H1",
- "L5H2",
- "L5H3",
- "L5H4",
- "L5H5",
- "L5H6",
- "L5H7",
- "L5H8",
- "L5H9",
- "L5H10",
- "L5H11",
- "L6H0",
- "L6H1",
- "L6H2",
- "L6H3",
- "L6H4",
- "L6H5",
- "L6H6",
- "L6H7",
- "L6H8",
- "L6H9",
- "L6H10",
- "L6H11",
- "L7H0",
- "L7H1",
- "L7H2",
- "L7H3",
- "L7H4",
- "L7H5",
- "L7H6",
- "L7H7",
- "L7H8",
- "L7H9",
- "L7H10",
- "L7H11",
- "L8H0",
- "L8H1",
- "L8H2",
- "L8H3",
- "L8H4",
- "L8H5",
- "L8H6",
- "L8H7",
- "L8H8",
- "L8H9",
- "L8H10",
- "L8H11",
- "L9H0",
- "L9H1",
- "L9H2",
- "L9H3",
- "L9H4",
- "L9H5",
- "L9H6",
- "L9H7",
- "L9H8",
- "L9H9",
- "L9H10",
- "L9H11",
- "L10H0",
- "L10H1",
- "L10H2",
- "L10H3",
- "L10H4",
- "L10H5",
- "L10H6",
- "L10H7",
- "L10H8",
- "L10H9",
- "L10H10",
- "L10H11",
- "L11H0",
- "L11H1",
- "L11H2",
- "L11H3",
- "L11H4",
- "L11H5",
- "L11H6",
- "L11H7",
- "L11H8",
- "L11H9",
- "L11H10",
- "L11H11"
- ],
- "legendgroup": "",
- "marker": {
- "color": "#636efa",
- "symbol": "circle"
- },
- "mode": "markers",
- "name": "",
- "orientation": "v",
- "showlegend": false,
- "type": "scatter",
- "x": [
- -0.002156503964215517,
- -0.0004650682385545224,
- 0.00024167183437384665,
- 0.0002806585980579257,
- -0.0004162999684922397,
- -0.0004892416181974113,
- -0.002620948012918234,
- -0.002935677068307996,
- 0.00042561208829283714,
- 0.0005418329383246601,
- 0.00023754138965159655,
- -7.48957390896976e-05,
- -0.000658505829051137,
- 0.0004060641804244369,
- -0.0009330413886345923,
- 0.0008937822422012687,
- -0.0009785268921405077,
- -0.000533820129930973,
- -0.0027988189831376076,
- -0.004214101936668158,
- 0.002578593324869871,
- 0.0024506838526576757,
- 0.0005351756699383259,
- 0.0012349633034318686,
- 0.0009405204327777028,
- -0.0011168691562488675,
- -0.0011541967978700995,
- -0.0015697095077484846,
- -0.0005699327448382974,
- 0.001451514894142747,
- 0.002439911477267742,
- 0.003158293664455414,
- 0.000923738582059741,
- -0.003578126197680831,
- -0.0010650777257978916,
- -0.0003558753523975611,
- -0.0005624951445497572,
- -1.1960582924075425e-05,
- 0.0011531109921634197,
- 0.0007360265008173883,
- 0.0016493839211761951,
- 0.0008800819050520658,
- -0.0006905529880896211,
- -0.003031972097232938,
- 0.0008080147090367973,
- 0.00010368914809077978,
- -0.0005807994166389108,
- -0.0011067037703469396,
- -0.0026375530287623405,
- 0.0002691895351745188,
- -0.0016417437000200152,
- -0.003406986128538847,
- 0.0017449699807912111,
- 0.00046454701805487275,
- -0.0007899806369096041,
- 0.0018328562146052718,
- -0.00086324627045542,
- -0.0003978293389081955,
- 0.0007879206677898765,
- -0.00012048585631418973,
- 0.0008688560919836164,
- 0.0009473530226387084,
- -0.0022812988609075546,
- -0.0011803123634308577,
- 0.0002407809515716508,
- -0.0004318578285165131,
- -0.0003728170122485608,
- -0.000738416681997478,
- 0.0008113418589346111,
- -0.00040444196201860905,
- -0.007074396125972271,
- 0.003946478478610516,
- -0.014917617663741112,
- -0.0022801742888987064,
- 0.0022679336834698915,
- -8.302251808345318e-05,
- -0.004980948753654957,
- 0.0027670026756823063,
- 0.006266288459300995,
- -0.003485947148874402,
- -0.0013348984066396952,
- -0.0017918883822858334,
- -0.0012231896398589015,
- 0.00040514359716326,
- -0.0002460568503011018,
- -0.005790225230157375,
- -0.0004975841729901731,
- 0.142182856798172,
- -0.0014961492270231247,
- -0.019006317481398582,
- 0.003133433870971203,
- -0.001858205534517765,
- -0.011305196210741997,
- 0.1922595500946045,
- -0.0011892566690221429,
- -0.0010282933944836259,
- -0.0038003993686288595,
- -0.0008570950012654066,
- -0.013956742361187935,
- 0.00828910805284977,
- 0.004315475933253765,
- -0.009073829278349876,
- -0.08315148949623108,
- 0.0034569751005619764,
- -0.01805492490530014,
- 0.002178061753511429,
- 0.29780513048171997,
- 0.02409379370510578,
- 0.08904723823070526,
- -0.0007931794971227646,
- 0.07247699797153473,
- 0.015016308054327965,
- -0.02120928093791008,
- 0.05205465108156204,
- 1.4411165714263916,
- 0.04743674397468567,
- -0.03229031339287758,
- 0,
- 0.0019993737805634737,
- -0.00807223655283451,
- 0.8600788116455078,
- 0.3260062038898468,
- 0.16344408690929413,
- 0.07133537530899048,
- -0.00444837287068367,
- 0.000681330740917474,
- 0.36613449454307556,
- -0.7105098962783813,
- -0.002031375654041767,
- -0.032143525779247284,
- 1.2294330596923828,
- 0.0018453558441251516,
- 0.016877274960279465,
- -0.001730365096591413,
- -0.5010868310928345,
- 0.02749764919281006,
- -0.0059662917628884315,
- -0.004944110754877329,
- -0.08855228126049042,
- 0.006622308399528265,
- 0.044124361127614975,
- -0.02726735547184944,
- -1.134916067123413,
- 0.02287953346967697
- ],
- "xaxis": "x",
- "y": [
- -0.0020563392899930477,
- -0.0005101899732835591,
- 0.0004685786843765527,
- 0.00012512074317783117,
- -0.0006028738571330905,
- -0.0002429460291750729,
- -0.0023189077619463205,
- -0.002758360467851162,
- 0.000564602785743773,
- 0.0009697531932033598,
- -0.0002504526637494564,
- 4.737317794933915e-06,
- -0.0010070882271975279,
- 0.00039470894262194633,
- -0.00154874159488827,
- 0.0014034928753972054,
- -0.0012653048615902662,
- -0.0011358022456988692,
- -0.00281596090644598,
- -0.0029645217582583427,
- 0.0029190476052463055,
- 0.0025743592996150255,
- 0.00036239007022231817,
- 0.0017548729665577412,
- 0.0005569400964304805,
- -0.001126631861552596,
- -0.0017353934235870838,
- -0.0014514457434415817,
- -0.00028735760133713484,
- 0.0017211002996191382,
- 0.0026658899150788784,
- 0.00311466702260077,
- 0.0005667927907779813,
- -0.003666515462100506,
- -0.0018847601022571325,
- 7.039372576400638e-06,
- -0.0007264417363330722,
- 0.00011364505917299539,
- 0.0014301587361842394,
- 0.0007490540738217533,
- 0.0020184689201414585,
- 0.0007436950691044331,
- -0.00046178390039131045,
- -0.0039057559333741665,
- 0.0011406694538891315,
- -4.022853681817651e-05,
- -0.0013293239753693342,
- -0.0017636751290410757,
- -0.0028280913829803467,
- 0.00033634810824878514,
- -0.0014248639345169067,
- -0.003777273464947939,
- 0.0015998880844563246,
- 0.0002989505883306265,
- -0.000804675742983818,
- 0.002038792008534074,
- -0.0015593919670209289,
- -0.0006436670082621276,
- 0.0011168173514306545,
- -0.00035012533771805465,
- 0.0011338205076754093,
- 0.0011259170714765787,
- -0.002516670385375619,
- -0.0014790185960009694,
- 0.0003878737334161997,
- -6.408110493794084e-05,
- -0.0005096744280308485,
- -0.0008840755908749998,
- 0.0006398351397365332,
- -0.0010097370250150561,
- -0.006759158335626125,
- 0.0033667823299765587,
- -0.01514742337167263,
- -0.0021350777242332697,
- 0.002593174111098051,
- -0.00042678468162193894,
- -0.005558924749493599,
- 0.0026658528950065374,
- 0.006411008536815643,
- -0.003826778382062912,
- -0.0003843410813715309,
- -0.0016430341638624668,
- -0.0013344454346224666,
- -9.20506427064538e-05,
- -9.476230479776859e-05,
- -0.0057889921590685844,
- -0.0006383581785485148,
- 0.13493388891220093,
- -0.001768707763403654,
- -0.018917907029390335,
- 0.003873429261147976,
- -0.0021450775675475597,
- -0.010327338241040707,
- 0.18325845897197723,
- -0.0007747983909212053,
- -0.00104526337236166,
- -0.003833949100226164,
- -0.0008046097937040031,
- -0.012673400342464447,
- 0.00804573018103838,
- 0.003604492638260126,
- -0.009398287162184715,
- -0.08272082358598709,
- 0.003555194940418005,
- -0.018404025584459305,
- 0.0017587244510650635,
- 0.2896133363246918,
- 0.022854052484035492,
- 0.08595258742570877,
- -0.0006932877004146576,
- 0.06817055493593216,
- 0.013111240230500698,
- -0.021098043769598007,
- 0.05112447217106819,
- 1.3844914436340332,
- 0.045836858451366425,
- -0.03830280900001526,
- 2.985445976257324,
- 0.0019662054255604744,
- -0.008030137047171593,
- 0.5608693957328796,
- 0.17083050310611725,
- -0.03361757844686508,
- 0.05821544677019119,
- -0.0024530249647796154,
- 0.0018771197646856308,
- 0.28827205300331116,
- -1.8986485004425049,
- -0.0015286931302398443,
- -0.035129792988300323,
- 0.4802178740501404,
- -0.0009115453576669097,
- 0.016075748950242996,
- -0.03986122086644173,
- -0.3879126012325287,
- 0.011123123578727245,
- -0.005477819126099348,
- -0.0025129620917141438,
- -0.08056175708770752,
- 0.007518616039305925,
- 0.0430111438035965,
- -0.040082238614559174,
- -0.9702364802360535,
- 0.011862239800393581
- ],
- "yaxis": "y"
- }
- ],
- "layout": {
- "legend": {
- "tracegroupgap": 0
- },
- "template": {
- "data": {
- "bar": [
- {
- "error_x": {
- "color": "#2a3f5f"
- },
- "error_y": {
- "color": "#2a3f5f"
- },
- "marker": {
- "line": {
- "color": "#E5ECF6",
- "width": 0.5
- },
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "bar"
- }
- ],
- "barpolar": [
- {
- "marker": {
- "line": {
- "color": "#E5ECF6",
- "width": 0.5
- },
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "barpolar"
- }
- ],
- "carpet": [
- {
- "aaxis": {
- "endlinecolor": "#2a3f5f",
- "gridcolor": "white",
- "linecolor": "white",
- "minorgridcolor": "white",
- "startlinecolor": "#2a3f5f"
- },
- "baxis": {
- "endlinecolor": "#2a3f5f",
- "gridcolor": "white",
- "linecolor": "white",
- "minorgridcolor": "white",
- "startlinecolor": "#2a3f5f"
- },
- "type": "carpet"
- }
- ],
- "choropleth": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "choropleth"
- }
- ],
- "contour": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "contour"
- }
- ],
- "contourcarpet": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "contourcarpet"
- }
- ],
- "heatmap": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "heatmap"
- }
- ],
- "heatmapgl": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "heatmapgl"
- }
- ],
- "histogram": [
- {
- "marker": {
- "pattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- }
- },
- "type": "histogram"
- }
- ],
- "histogram2d": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "histogram2d"
- }
- ],
- "histogram2dcontour": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "histogram2dcontour"
- }
- ],
- "mesh3d": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "type": "mesh3d"
- }
- ],
- "parcoords": [
- {
- "line": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "parcoords"
- }
- ],
- "pie": [
- {
- "automargin": true,
- "type": "pie"
- }
- ],
- "scatter": [
- {
- "fillpattern": {
- "fillmode": "overlay",
- "size": 10,
- "solidity": 0.2
- },
- "type": "scatter"
- }
- ],
- "scatter3d": [
- {
- "line": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatter3d"
- }
- ],
- "scattercarpet": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattercarpet"
- }
- ],
- "scattergeo": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattergeo"
- }
- ],
- "scattergl": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattergl"
- }
- ],
- "scattermapbox": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scattermapbox"
- }
- ],
- "scatterpolar": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterpolar"
- }
- ],
- "scatterpolargl": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterpolargl"
- }
- ],
- "scatterternary": [
- {
- "marker": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "type": "scatterternary"
- }
- ],
- "surface": [
- {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- },
- "colorscale": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "type": "surface"
- }
- ],
- "table": [
- {
- "cells": {
- "fill": {
- "color": "#EBF0F8"
- },
- "line": {
- "color": "white"
- }
- },
- "header": {
- "fill": {
- "color": "#C8D4E3"
- },
- "line": {
- "color": "white"
- }
- },
- "type": "table"
- }
- ]
- },
- "layout": {
- "annotationdefaults": {
- "arrowcolor": "#2a3f5f",
- "arrowhead": 0,
- "arrowwidth": 1
- },
- "autotypenumbers": "strict",
- "coloraxis": {
- "colorbar": {
- "outlinewidth": 0,
- "ticks": ""
- }
- },
- "colorscale": {
- "diverging": [
- [
- 0,
- "#8e0152"
- ],
- [
- 0.1,
- "#c51b7d"
- ],
- [
- 0.2,
- "#de77ae"
- ],
- [
- 0.3,
- "#f1b6da"
- ],
- [
- 0.4,
- "#fde0ef"
- ],
- [
- 0.5,
- "#f7f7f7"
- ],
- [
- 0.6,
- "#e6f5d0"
- ],
- [
- 0.7,
- "#b8e186"
- ],
- [
- 0.8,
- "#7fbc41"
- ],
- [
- 0.9,
- "#4d9221"
- ],
- [
- 1,
- "#276419"
- ]
- ],
- "sequential": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ],
- "sequentialminus": [
- [
- 0,
- "#0d0887"
- ],
- [
- 0.1111111111111111,
- "#46039f"
- ],
- [
- 0.2222222222222222,
- "#7201a8"
- ],
- [
- 0.3333333333333333,
- "#9c179e"
- ],
- [
- 0.4444444444444444,
- "#bd3786"
- ],
- [
- 0.5555555555555556,
- "#d8576b"
- ],
- [
- 0.6666666666666666,
- "#ed7953"
- ],
- [
- 0.7777777777777778,
- "#fb9f3a"
- ],
- [
- 0.8888888888888888,
- "#fdca26"
- ],
- [
- 1,
- "#f0f921"
- ]
- ]
- },
- "colorway": [
- "#636efa",
- "#EF553B",
- "#00cc96",
- "#ab63fa",
- "#FFA15A",
- "#19d3f3",
- "#FF6692",
- "#B6E880",
- "#FF97FF",
- "#FECB52"
- ],
- "font": {
- "color": "#2a3f5f"
- },
- "geo": {
- "bgcolor": "white",
- "lakecolor": "white",
- "landcolor": "#E5ECF6",
- "showlakes": true,
- "showland": true,
- "subunitcolor": "white"
- },
- "hoverlabel": {
- "align": "left"
- },
- "hovermode": "closest",
- "mapbox": {
- "style": "light"
- },
- "paper_bgcolor": "white",
- "plot_bgcolor": "#E5ECF6",
- "polar": {
- "angularaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "bgcolor": "#E5ECF6",
- "radialaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- }
- },
- "scene": {
- "xaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- },
- "yaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- },
- "zaxis": {
- "backgroundcolor": "#E5ECF6",
- "gridcolor": "white",
- "gridwidth": 2,
- "linecolor": "white",
- "showbackground": true,
- "ticks": "",
- "zerolinecolor": "white"
- }
- },
- "shapedefaults": {
- "line": {
- "color": "#2a3f5f"
- }
- },
- "ternary": {
- "aaxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "baxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- },
- "bgcolor": "#E5ECF6",
- "caxis": {
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": ""
- }
- },
- "title": {
- "x": 0.05
- },
- "xaxis": {
- "automargin": true,
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": "",
- "title": {
- "standoff": 15
- },
- "zerolinecolor": "white",
- "zerolinewidth": 2
- },
- "yaxis": {
- "automargin": true,
- "gridcolor": "white",
- "linecolor": "white",
- "ticks": "",
- "title": {
- "standoff": 15
- },
- "zerolinecolor": "white",
- "zerolinewidth": 2
- }
- }
- },
- "title": {
- "text": "Original vs Post-Ablation Direct Logit Attribution of Heads"
- },
- "xaxis": {
- "anchor": "y",
- "domain": [
- 0,
- 1
- ],
- "range": [
- -3,
- 3
- ],
- "title": {
- "text": "Ablated"
- }
- },
- "yaxis": {
- "anchor": "x",
- "domain": [
- 0,
- 1
- ],
- "range": [
- -3,
- 3
- ],
- "title": {
- "text": "Original"
- }
- }
- }
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"per_head_ablated_residual, labels = ablated_cache.stack_head_results(\n",
" layer=-1, pos_slice=-1, return_labels=True\n",
@@ -20265,33 +1827,9 @@
},
{
"cell_type": "code",
- "execution_count": 40,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Average LN scaling ratio: 1.042\n",
- "Ablation LN scale tensor([[18.5200],\n",
- " [17.4700],\n",
- " [17.8200],\n",
- " [17.5100],\n",
- " [17.2600],\n",
- " [18.2500],\n",
- " [16.1800],\n",
- " [17.4300]])\n",
- "Original LN scale tensor([[19.5700],\n",
- " [18.3500],\n",
- " [18.2900],\n",
- " [18.6800],\n",
- " [17.4900],\n",
- " [18.8700],\n",
- " [16.4200],\n",
- " [18.6800]])\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"print(\n",
" \"Average LN scaling ratio:\",\n",
@@ -20326,7 +1864,7 @@
],
"metadata": {
"kernelspec": {
- "display_name": ".venv",
+ "display_name": "transformer-lens",
"language": "python",
"name": "python3"
},
@@ -20340,14 +1878,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.11.5"
- },
- "vscode": {
- "interpreter": {
- "hash": "eb812820b5094695c8a581672e17220e30dd2c15d704c018326e3cc2e1a566f1"
- }
+ "version": "3.12.12"
}
},
"nbformat": 4,
"nbformat_minor": 2
-}
+}
\ No newline at end of file
diff --git a/transformer_lens/ActivationCache.py b/transformer_lens/ActivationCache.py
index 55cdbf34a..cf93fb8ec 100644
--- a/transformer_lens/ActivationCache.py
+++ b/transformer_lens/ActivationCache.py
@@ -677,9 +677,25 @@ def compute_head_results(
Intended use is to enable use_attn_results when running and caching the model, but this can
be useful if you forget.
"""
- if "blocks.0.attn.hook_result" in self.cache_dict:
- logging.warning("Tried to compute head results when they were already cached")
- return
+ # If valid 4D per-head results already exist (from forward pass with
+ # use_attn_result=True, or from a prior compute_head_results() call),
+ # return early to preserve idempotency.
+ #
+ # TransformerBridge may populate hook_result with a 3D combined-output
+ # tensor (from the hook_result → hook_out alias). We detect these
+ # wrong-shape entries by checking ndim and remove them before
+ # recomputing the correct 4D per-head results from z and W_O.
+ first_key = "blocks.0.attn.hook_result"
+ if first_key in self.cache_dict:
+ val = self.cache_dict[first_key]
+ if isinstance(val, torch.Tensor) and val.ndim >= 4:
+ logging.warning("Tried to compute head results when they were already cached")
+ return
+ # Stale 3D entries exist — remove them before recomputing
+ for layer in range(self.model.cfg.n_layers):
+ key = f"blocks.{layer}.attn.hook_result"
+ if key in self.cache_dict:
+ del self.cache_dict[key]
for layer in range(self.model.cfg.n_layers):
# Note that we haven't enabled set item on this object so we need to edit the underlying
# cache_dict directly.
@@ -734,11 +750,11 @@ def stack_head_results(
# Default to the residual stream immediately pre unembed
layer = self.model.cfg.n_layers
- if "blocks.0.attn.hook_result" not in self.cache_dict:
- print(
- "Tried to stack head results when they weren't cached. Computing head results now"
- )
- self.compute_head_results()
+ # Always call compute_head_results() – it handles idempotency
+ # (returns early for valid 4D data) and also cleans up any stale 3D
+ # entries that TransformerBridge's hook_result alias may have placed
+ # in the cache.
+ self.compute_head_results()
components: Any = []
labels = []
diff --git a/transformer_lens/model_bridge/bridge.py b/transformer_lens/model_bridge/bridge.py
index 6e738bcd1..6d7337bd8 100644
--- a/transformer_lens/model_bridge/bridge.py
+++ b/transformer_lens/model_bridge/bridge.py
@@ -206,8 +206,6 @@ def _register_aliases(self) -> None:
for part in single_target.split("."):
target_obj = getattr(target_obj, part)
object.__setattr__(self, alias_name, target_obj)
- if isinstance(target_obj, HookPoint):
- target_obj.name = alias_name
break
except AttributeError:
continue
@@ -216,8 +214,6 @@ def _register_aliases(self) -> None:
for part in target_path.split("."):
target_obj = getattr(target_obj, part)
object.__setattr__(self, alias_name, target_obj)
- if isinstance(target_obj, HookPoint):
- target_obj.name = alias_name
except AttributeError:
pass
@@ -405,6 +401,11 @@ def _add_aliases_to_hooks(self, hooks: Dict[str, HookPoint]) -> None:
def _scan_existing_hooks(self, module: nn.Module, prefix: str = "") -> None:
"""Scan existing modules for hooks and add them to registry."""
visited = set()
+ # Track which HookPoint objects have already been named so that
+ # alias entries (from get_hooks() in compatibility mode) do not
+ # overwrite the canonical name. get_hooks() returns canonical
+ # entries first, so the first name assigned is always canonical.
+ named_hook_ids: set = set()
def scan_module(mod: nn.Module, path: str = "") -> None:
obj_id = id(mod)
@@ -417,7 +418,10 @@ def scan_module(mod: nn.Module, path: str = "") -> None:
hooks_dict = cast(Dict[str, HookPoint], component_hooks)
for hook_name, hook in hooks_dict.items():
full_name = f"{path}.{hook_name}" if path else hook_name
- hook.name = full_name
+ hook_id = id(hook)
+ if hook_id not in named_hook_ids:
+ hook.name = full_name
+ named_hook_ids.add(hook_id)
self._hook_registry[full_name] = hook
for attr_name in dir(mod):
if attr_name.startswith("_"):
@@ -448,7 +452,10 @@ def scan_module(mod: nn.Module, path: str = "") -> None:
continue
name = f"{path}.{attr_name}" if path else attr_name
if isinstance(attr, HookPoint):
- attr.name = name
+ hook_id = id(attr)
+ if hook_id not in named_hook_ids:
+ attr.name = name
+ named_hook_ids.add(hook_id)
self._hook_registry[name] = attr
for child_name, child_module in mod.named_children():
if (