On a prompt made of a random sequence of length followed by the same sequence again, an induction head attends from each token in the second copy to the token that followed its first occurrence, which sits positions back. A duplicate-token head attends to the first occurrence itself, positions back. Score both.
induction_score(A, n, decimals=4)
A is (H, 2n, 2n) attention on a repeated sequence. For each head return the mean over second-copy queries of , rounded. The first second-copy query () looks at position , the token after the first token.duplicate_token_score(A, n, decimals=4)
find_induction_heads(A, n, threshold=0.5)
threshold.induction_pattern(n)
(2n, 2n) ideal induction pattern: for all mass on ; for all mass on position (no information yet, so the sink). Useful as a reference head.np.arange(n, 2 * n).