{ "task": { "id": "case_25", "name": "token_frequency_normalization", "summary": "Normalizes token frequencies in a sequence to a range between 0 and 1.", "examples": [ { "input": [ "BOS", "b", "b", "a", "a", "b", "b", "a", "a", "a" ], "output": [ "BOS", 0.4444444444444444, 0.4444444444444444, 0.5555555555555556, 0.5555555555555556, 0.4444444444444444, 0.4444444444444444, 0.5555555555555556, 0.5555555555555556, 0.5555555555555556 ] }, { "input": [ "BOS", "c", "c", "a", "c", "a", "c", "c", "a", "a" ], "output": [ "BOS", 0.5555555555555556, 0.5555555555555556, 0.4444444444444444, 0.5555555555555556, 0.4444444444444444, 0.5555555555555556, 0.5555555555555556, 0.4444444444444444, 0.4444444444444444 ] }, { "input": [ "BOS", "c", "a", "c", "c", "a", "a", "c", "b", "c" ], "output": [ "BOS", 0.5555555555555556, 0.3333333333333333, 0.5555555555555556, 0.5555555555555556, 0.3333333333333333, 0.3333333333333333, 0.5555555555555556, 0.1111111111111111, 0.5555555555555556 ] }, { "input": [ "BOS", "c", "c", "c", "b", "c", "b", "b", "c", "b" ], "output": [ "BOS", 0.5555555555555556, 0.5555555555555556, 0.5555555555555556, 0.4444444444444444, 0.5555555555555556, 0.4444444444444444, 0.4444444444444444, 0.5555555555555556, 0.4444444444444444 ] }, { "input": [ "BOS", "c", "c", "c", "a", "c", "b", "a", "b", "b" ], "output": [ "BOS", 0.4444444444444444, 0.4444444444444444, 0.4444444444444444, 0.2222222222222222, 0.4444444444444444, 0.3333333333333333, 0.2222222222222222, 0.3333333333333333, 0.3333333333333333 ] } ], "is_categorical": true }, "program": "normalized_freq = rasp.SequenceMap(lambda x, y: (x / y) if y > 0 else None, make_hist(), make_length())\nreturn normalized_freq", "components": [ { "id": "L0H0_ATTN", "hook": "blocks.0.attn.hook_result[0]", "role": { "tag": "AGGREGATOR", "note": "Builds the token-matching pattern used to count how often each token appears." }, "rasp_vars": [ "same_tok" ], "labels": [ "hist_2_selector_width_attn_output" ] }, { "id": "L0H1_ATTN", "hook": "blocks.0.attn.hook_result[1]", "role": { "tag": "AGGREGATOR", "note": "Builds the all-positions pattern used to compute the sequence length." }, "rasp_vars": [ "all_true_selector" ], "labels": [ "length_3_selector_width_attn_output" ] }, { "id": "L0_MLP", "hook": "blocks.0.mlp.hook_post", "role": { "tag": "MAPPER", "note": "Post-processes the two attention outputs into usable per-position features of token frequency count and sequence length." }, "rasp_vars": [ "hist", "length" ], "labels": [ "hist_2", "length_3", "hist_2_selector_width_attn_output", "length_3_selector_width_attn_output" ] }, { "id": "L1_MLP", "hook": "blocks.1.mlp.hook_post", "role": { "tag": "COMBINER", "note": "Combines the per-token frequency with the sequence length to output normalized frequencies in the 0-1 range." }, "rasp_vars": [ "normalized_freq" ], "labels": [ "sequence_map_1" ] } ] }