Using the toy residual model from the patching problems (embedding plus component writes at each position, a reader head at the last position), evaluate a candidate circuit, a set of component indices, with the three standard tests.
reader_metric(R, W_r, d_vec) and assemble(embed, writes) as before: scores , softmax over positions, metric d_vec dotted with the attended mixture; residuals embed + writes.sum(axis=0).
metric_with(embed, writes, keep, mean_writes, W_r, d_vec)
keep is an iterable of component indices. Replace every component not in keep by its mean write (from mean_writes, shaped like writes) and return the metric.circuit_scores(embed, writes, circuit, mean_writes, W_r, d_vec, decimals=4)
m_full the metric of the intact model and m_none the metric with every component mean-ablated, return a dict:
"faithfulness": (metric_with(circuit) - m_none) / (m_full - m_none),"completeness": (metric_with(complement) - m_none) / (m_full - m_none) where the complement is every component not in the circuit (low means the circuit is needed),"minimality": a dict mapping each component c in the circuit to faithfulness(circuit) - faithfulness(circuit without c).m_full == m_none return zeros.prune_circuit(embed, writes, circuit, mean_writes, W_r, d_vec, min_drop)
min_drop, and return the sorted remaining circuit.set(range(C)) - set(circuit).1 and of the empty set is 0; use those as sanity checks.