Docstring official
auto_circuit.metrics.official_circuits.circuits.docstring_official
Classes
Functions
docstring_node_based_official_edges
docstring_node_based_official_edges(model: PatchableModel, token_positions: bool = False, word_idxs: Dict[str, int] = {}, seq_start_idx: int = 0) -> Set[Edge]
The attention heads in the Docstring circuit, from the blog post by Stefan Heimersheim and Jett Janiak (2023).
In the blog post, to measure the overall performance of the circuit, the authors Node Patch the heads in the circuit, rather than Edge Patching the specific edges they find. We include this variation to enable replication of these results.
The token positions are based on my reading of the paper, but some were unspecified
so in those cases we include all token positions between A_def
and param_3
.
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/docstring_official.py
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 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
|
docstring_true_edges
docstring_true_edges(model: PatchableModel, token_positions: bool = False, word_idxs: Dict[str, int] = {}, seq_start_idx: int = 0) -> Set[Edge]
The Docstring circuit, from the blog post by Stefan Heimersheim and Jett Janiak (2023).
The exact set of edges was defined by Stephan in the ACDC repo. The token positions are based on my reading of the paper, but I have been over them briefly with Stefan and he endorsed them as reasonable.
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. |