{ "task": { "id": "case_18", "name": "token_frequency_classifier", "summary": "Classify each token based on its frequency as 'rare', 'common', or 'frequent'.", "examples": [ { "input": [ "BOS", "a", "d", "b", "e", "d", "a", "a", "c", "c" ], "output": [ "BOS", "common", "rare", "rare", "rare", "rare", "common", "common", "rare", "rare" ] }, { "input": [ "BOS", "b", "d", "d", "c", "d", "d", "a", "c", "e" ], "output": [ "BOS", "rare", "common", "common", "rare", "common", "common", "rare", "rare", "rare" ] }, { "input": [ "BOS", "c", "e", "a", "b", "d", "a", "d", "b", "b" ], "output": [ "BOS", "rare", "rare", "rare", "common", "rare", "rare", "rare", "common", "common" ] }, { "input": [ "BOS", "e", "d", "c", "e", "b", "d", "b", "d", "e" ], "output": [ "BOS", "common", "common", "rare", "common", "rare", "common", "rare", "common", "common" ] }, { "input": [ "BOS", "d", "e", "c", "e", "e", "b", "c", "c", "c" ], "output": [ "BOS", "rare", "common", "common", "common", "common", "rare", "common", "common", "common" ] } ], "is_categorical": true }, "program": "frequency = make_hist()\ntotal_tokens = make_length()\nfrequency_classification = rasp.SequenceMap(\n lambda freq, total: \"frequent\" if freq > total/2 else (\"common\" if freq > total/4 else \"rare\"),\n frequency, total_tokens)\nreturn frequency_classification", "components": [ { "id": "L0H0_ATTN", "hook": "blocks.0.attn.hook_result[0]", "role": { "tag": "AGGREGATOR", "note": "Builds the token-equality matching structure 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 selector used as the basis for computing 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": "Turns the selector-width signals into usable numeric features for per-token frequency and total length." }, "rasp_vars": [ "frequency", "total_tokens" ], "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 per-token frequency with total length to assign the label rare/common/frequent." }, "rasp_vars": [ "frequency_classification" ], "labels": [ "sequence_map_1" ] } ] }