{ "task": { "id": "case_19", "name": "sequential_duplicate_removal", "summary": "Removes consecutive duplicate tokens from a sequence.", "examples": [ { "input": [ "BOS", "c", "a", "c", "c", "a", "a", "c", "b", "c", "c", "c", "c", "a", "c" ], "output": [ "BOS", null, "a", "c", null, "a", null, "c", "b", "c", null, null, null, "a", "c" ] }, { "input": [ "BOS", "c", "c", "b", "c", "b", "b", "c", "b", "c", "c", "a", "c", "a", "c" ], "output": [ "BOS", null, null, "b", "c", "b", null, "c", "b", "c", null, "a", "c", "a", "c" ] }, { "input": [ "BOS", "c", "a", "a", "c", "b", "a", "b", "b", "b", "a", "b", "a", "b", "c" ], "output": [ "BOS", null, "a", null, "c", "b", "a", "b", null, null, "a", "b", "a", "b", "c" ] }, { "input": [ "BOS", "c", "a", "c", "c", "b", "a", "b", "b", "b", "b", "b", "b", "b", "a" ], "output": [ "BOS", null, "a", "c", null, "b", "a", "b", null, null, null, null, null, null, "a" ] }, { "input": [ "BOS", "b", "a", "b", "b", "b", "b", "a", "a", "b", "b", "a", "a", "a", "c" ], "output": [ "BOS", null, "a", "b", null, null, null, "a", null, "b", null, "a", null, null, "c" ] } ], "is_categorical": true }, "program": "shifted_sop = shift_by(1, sop)\nduplicate_removal_sop = rasp.SequenceMap(lambda x, y: x if x != y else None, sop, shifted_sop).named(\"sequential_duplicate_removal\")\nreturn duplicate_removal_sop", "components": [ { "id": "L0H0_ATTN", "hook": "blocks.0.attn.hook_result[0]", "role": { "tag": "ROUTER", "note": "Shifts the sequence by one position to expose the previous token at each index for comparison." }, "rasp_vars": [ "shifted_sop" ], "labels": [ "shift_by(1)_2" ] }, { "id": "L0_MLP", "hook": "blocks.0.mlp.hook_post", "role": { "tag": "COMBINER", "note": "Compares each token to the previous token and outputs the token only when it differs; otherwise outputs None to remove consecutive duplicates." }, "rasp_vars": [ "sequential_duplicate_removal" ], "labels": [ "sequential_duplicate_removal_1" ] } ] }