Train same under knockouts
auto_circuit.metrics.completeness_metrics.train_same_under_knockouts
Attributes
Classes
Functions
train_same_under_knockout_prune_scores
train_same_under_knockout_prune_scores(task: Task, algo: PruneAlgo, algo_ps: PruneScores, circuit_size: int, learning_rate: float, epochs: int, regularize_lambda: float, mask_fn: MaskFn = 'hard_concrete', faithfulness_target: Literal['kl_div', 'logit_diff'] = 'kl_div') -> PruneScores
Learn a subset of the circuit to ablate such that when the same edges are ablated from the full model, the KL divergence between the circuit and the full model is maximized.
See:
same_under_knockouts
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task |
Task
|
The task to train on. |
required |
algo |
PruneAlgo
|
The pruning algorithm used to generate the circuit. This value is only used for visualization purposes. |
required |
algo_ps |
PruneScores
|
The pruning scores for the algorithm. The circuit is defined as the
top |
required |
circuit_size |
int
|
The size of the circuit to knockout. |
required |
learning_rate |
float
|
The learning rate for the optimization. |
required |
epochs |
int
|
The number of epochs to train for. |
required |
regularize_lambda |
float
|
The regularization strength for the number of edges that are knocked out. Can reasonably be set to 0. |
required |
mask_fn |
MaskFn
|
The mask parameterization to use for the optimization. |
'hard_concrete'
|
faithfulness_target |
Literal['kl_div', 'logit_diff']
|
The target for the faithfulness term in the loss. The optimizer will try to maximize the difference in this target between the knocked-out circuit and the knocked-out full model. |
'kl_div'
|
Returns:
Type | Description |
---|---|
PruneScores
|
The learned ordering of edges to knockout. |
Source code in auto_circuit/metrics/completeness_metrics/train_same_under_knockouts.py
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 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
|
train_same_under_knockouts
train_same_under_knockouts(task_prune_scores: TaskPruneScores, algo_keys: List[AlgoKey], learning_rate: float, epochs: int, regularize_lambda: float, faithfulness_target: Literal['kl_div', 'logit_diff'] = 'kl_div') -> TaskPruneScores
Wrapper of
train_same_under_knockout_prune_scores
for multiple tasks and algorithms.