Ioi official
auto_circuit.metrics.official_circuits.circuits.ioi_official
Classes
Functions
ioi_head_based_official_edges
ioi_head_based_official_edges(model: PatchableModel, token_positions: bool = False, word_idxs: Dict[str, int] = {}, seq_start_idx: int = 0) -> Set[Edge]
Node-based circuit of the IOI attention heads.
To measure the performance of their circuit, Wang et al. (2022) Mean Ablate the heads in the circuit, rather than Edge Ablating the specific edges they find (means calculated over ABC dataset). We include this variation to enable replication of these results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model |
PatchableModel
|
A patchable TransformerLens GPT-2 |
required |
token_positions |
bool
|
Whether to distinguish between token positions when returning
the set of circuit edges. If |
False
|
word_idxs |
Dict[str, int]
|
A dictionary defining the index of specific named tokens in the circuit definition. For this circuit, the required tokens positions are:
|
{}
|
seq_start_idx |
int
|
Offset to add to all of the token positions in |
0
|
Returns:
Type | Description |
---|---|
Set[Edge]
|
The set of edges in the circuit. |
Source code in auto_circuit/metrics/official_circuits/circuits/ioi_official.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
|
ioi_true_edges
ioi_true_edges(model: PatchableModel, token_positions: bool = False, word_idxs: Dict[str, int] = {}, seq_start_idx: int = 0) -> Set[Edge]
The Indirect Object Identification (IOI) circuit, discovered by Wang et al. (2022).
The exact set of edges was defined by Conmy et al. in the ACDC repo.
The token positions are based on my reading of the paper.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model |
PatchableModel
|
A patchable TransformerLens GPT-2 |
required |
token_positions |
bool
|
Whether to distinguish between token positions when returning
the set of circuit edges. If |
False
|
word_idxs |
Dict[str, int]
|
A dictionary defining the index of specific named tokens in the circuit definition. For this circuit, the required tokens positions are:
|
{}
|
seq_start_idx |
int
|
Offset to add to all of the token positions in |
0
|
Returns:
Type | Description |
---|---|
Set[Edge]
|
The set of edges in the circuit. |
Source code in auto_circuit/metrics/official_circuits/circuits/ioi_official.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
|
ioi_true_edges_mlp_0_only
ioi_true_edges_mlp_0_only(model: PatchableModel, token_positions: bool = False, word_idxs: Dict[str, int] = {}, seq_start_idx: int = 0) -> Set[Edge]
Wrapper for
ioi_true_edges
that removes all edges to or from all MLPs except MLP 0.
Wang et al. (2022) consider MLPs to be part of the direct path between attention heads, so they implicitly include a large number of MLP edges in the circuit, but they did not study these interactions in detail and most of them are probably not important.
Therefore we include this function as a very rough attempt at "the IOI circuit with fewer unnecessary MLP edges". We include just MLP 0 because it has been widely observed that MLP 0 tends to be the most important MLP layer in GPT-2.