diff --git a/annotations/case_101.json b/annotations/case_101.json new file mode 100644 index 0000000000000000000000000000000000000000..0666c14599a44b134bbd47cc1e674a37a7f7a577 --- /dev/null +++ b/annotations/case_101.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_101", + "name": "check_square", + "summary": "Check if each element is a square of an integer.", + "examples": [ + { + "input": [ + "BOS", + 6, + 19, + 28, + 14, + 10, + 7, + 28, + 20, + 6 + ], + "output": [ + "BOS", + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + }, + { + "input": [ + "BOS", + 25, + 18, + 22, + 10, + 10, + 23, + 20, + 3, + 7 + ], + "output": [ + "BOS", + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + }, + { + "input": [ + "BOS", + 24, + 16, + 26, + 26, + 9, + 27, + 27, + 15, + 14 + ], + "output": [ + "BOS", + 0, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 0 + ] + }, + { + "input": [ + "BOS", + 1, + 27, + 20, + 0, + 11, + 25, + 21, + 28, + 11 + ], + "output": [ + "BOS", + 1, + 0, + 0, + 1, + 0, + 1, + 0, + 0, + 0 + ] + }, + { + "input": [ + "BOS", + 23, + 2, + 21, + 20, + 1, + 23, + 11, + 29, + 5 + ], + "output": [ + "BOS", + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0 + ] + } + ], + "is_categorical": true + }, + "program": "check_square = rasp.Map(lambda x: 1 if x ** 0.5 == int(x ** 0.5) else 0, rasp.tokens).named(\"check_square\")\nreturn check_square", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "INDICATOR", + "note": "Evaluates each element independently and checks if it is a perfect square." + }, + "rasp_vars": [ + "check_square" + ], + "labels": [ + "map_1" + ] + } + ] +} diff --git a/annotations/case_102.json b/annotations/case_102.json new file mode 100644 index 0000000000000000000000000000000000000000..7dccdd702d85d874d07b114ff748a34edf462fd0 --- /dev/null +++ b/annotations/case_102.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_102", + "name": "reflect_into_range", + "summary": "Reflects each element within a range (default is [2, 7]).", + "examples": [ + { + "input": [ + "BOS", + -3, + -17, + 4, + -7, + -12, + 5, + -19, + -1, + 7 + ], + "output": [ + "BOS", + 7, + 3, + 4, + 3, + 6, + 5, + 3, + 5, + 7 + ] + }, + { + "input": [ + "BOS", + -10, + 3, + 15, + 19, + 3, + -18, + 1, + -19, + 3 + ], + "output": [ + "BOS", + 4, + 3, + 5, + 5, + 3, + 2, + 3, + 3, + 3 + ] + }, + { + "input": [ + "BOS", + 18, + 8, + -6, + -13, + 0, + 18, + -2, + 2, + -10 + ], + "output": [ + "BOS", + 6, + 6, + 4, + 7, + 4, + 6, + 6, + 2, + 4 + ] + }, + { + "input": [ + "BOS", + 9, + 17, + -19, + 0, + 12, + -9, + 1, + 4, + 6 + ], + "output": [ + "BOS", + 5, + 7, + 3, + 4, + 2, + 3, + 3, + 4, + 6 + ] + }, + { + "input": [ + "BOS", + 7, + -5, + -6, + -18, + 16, + -14, + 0, + -12, + 18 + ], + "output": [ + "BOS", + 7, + 5, + 4, + 2, + 6, + 6, + 4, + 6, + 6 + ] + } + ], + "is_categorical": true + }, + "program": "return rasp.Map(lambda x: reflect_into_range(max_val, min_val, x), rasp.tokens)", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Applies a per-element reflection rule to fold values back into the target range." + }, + "rasp_vars": [ + "reflected_sequence" + ], + "labels": [ + "map_1" + ] + } + ] +} diff --git a/annotations/case_103.json b/annotations/case_103.json new file mode 100644 index 0000000000000000000000000000000000000000..f19c626cb27680a26422ada4842c071b46f1b192 --- /dev/null +++ b/annotations/case_103.json @@ -0,0 +1,200 @@ +{ + "task": { + "id": "case_103", + "name": "swap_consecutive", + "summary": "Swap consecutive numbers in a list.", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 4.0, + 2.0, + 6.0, + 2.0, + 8.0, + 4.0, + 1.0, + 6.0, + 3.0 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 1.0, + 4.0, + 5.0, + 7.0, + 4.0, + 1.0, + 9.0, + 0.0, + 5.0 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 10.0, + 10.0, + 4.0, + 7.0, + 7.0, + 3.0, + 2.0, + 7.0, + 5.0 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 0.0, + 8.0, + 10.0, + 10.0, + 2.0, + 9.0, + 3.0, + 6.0, + 8.0 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 3.0, + 6.0, + 7.0, + 10.0, + 6.0, + 4.0, + 2.0, + 9.0, + 6.0 + ] + } + ], + "is_categorical": true + }, + "program": "len = rasp.SelectorWidth(rasp.Select(rasp.indices, rasp.indices, rasp.Comparison.TRUE)).named('len')\nswaper = rasp.SequenceMap(lambda idx, L: idx if (idx == L - 1 and idx % 2 == 0) else (idx + 1 if idx % 2 == 0 else idx - 1), rasp.indices, len).named('swaper')\nswap_selector = rasp.Select(rasp.indices, swaper, rasp.Comparison.EQ).named('swap_selector')\nswapped = rasp.Aggregate(swap_selector, rasp.tokens).named('swapped')\nreturn swapped", + "components": [ + { + "id": "L0H0_ATTN", + "hook": "blocks.0.attn.hook_result[0]", + "role": { + "tag": "AGGREGATOR", + "note": "Produces a shared sequence-level size signal used to handle the last element correctly during swapping." + }, + "rasp_vars": [ + "len" + ], + "labels": [ + "selector_width_4_selector_width_attn_output" + ] + }, + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Turns the length-related signal into a sequence-length feature." + }, + "rasp_vars": [ + "len" + ], + "labels": [ + "selector_width_4_selector_width_attn_output", + "selector_width_4" + ] + }, + { + "id": "L1_MLP", + "hook": "blocks.1.mlp.hook_post", + "role": { + "tag": "COMBINER", + "note": "For each position, computes the index of the element it should swap with (neighbor, with end-of-sequence handling)." + }, + "rasp_vars": [ + "swaper" + ], + "labels": [ + "sequence_map_3" + ] + }, + { + "id": "L2H0_ATTN", + "hook": "blocks.2.attn.hook_result[0]", + "role": { + "tag": "ROUTER", + "note": "Moves values so each position receives the value from its swap partner." + }, + "rasp_vars": [ + "swapped" + ], + "labels": [ + "aggregate_1" + ] + } + ] +} diff --git a/annotations/case_104.json b/annotations/case_104.json new file mode 100644 index 0000000000000000000000000000000000000000..1202ac8aaeb87a2b01961dde99579940138c9bf4 --- /dev/null +++ b/annotations/case_104.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_104", + "name": "exponential", + "summary": "Apply exponential function to all elements of the input sequence.", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 7.38905609893065, + 54.598150033144236, + 7.38905609893065, + 403.4287934927351, + 54.598150033144236, + 2980.9579870417283, + 403.4287934927351, + 2.718281828459045, + 20.085536923187668 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 54.598150033144236, + 2.718281828459045, + 1096.6331584284585, + 148.4131591025766, + 2.718281828459045, + 54.598150033144236, + 1.0, + 8103.083927575384, + 148.4131591025766 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 22026.465794806718, + 22026.465794806718, + 1096.6331584284585, + 54.598150033144236, + 20.085536923187668, + 1096.6331584284585, + 1096.6331584284585, + 7.38905609893065, + 148.4131591025766 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 2980.9579870417283, + 1.0, + 22026.465794806718, + 22026.465794806718, + 8103.083927575384, + 7.38905609893065, + 403.4287934927351, + 20.085536923187668, + 2980.9579870417283 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 403.4287934927351, + 20.085536923187668, + 22026.465794806718, + 1096.6331584284585, + 54.598150033144236, + 403.4287934927351, + 8103.083927575384, + 7.38905609893065, + 403.4287934927351 + ] + } + ], + "is_categorical": true + }, + "program": "exp_approx = rasp.Map(lambda x: math.exp(x), rasp.tokens)\nreturn exp_approx", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Applies an element-wise exponential transformation to each input element." + }, + "rasp_vars": [ + "exp_approx" + ], + "labels": [ + "map_1" + ] + } + ] +} diff --git a/annotations/case_105.json b/annotations/case_105.json new file mode 100644 index 0000000000000000000000000000000000000000..841a189172caebd103b3c03e6c4c5c5f2ec0cbf0 --- /dev/null +++ b/annotations/case_105.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_105", + "name": "next_prime", + "summary": "Replaces each number with the next prime after that number.", + "examples": [ + { + "input": [ + "BOS", + 6, + 19, + 28, + 14, + 10, + 7, + 28, + 20, + 6 + ], + "output": [ + "BOS", + 7, + 19, + 29, + 17, + 11, + 7, + 29, + 23, + 7 + ] + }, + { + "input": [ + "BOS", + 25, + 18, + 22, + 10, + 10, + 23, + 20, + 3, + 7 + ], + "output": [ + "BOS", + 29, + 19, + 23, + 11, + 11, + 23, + 23, + 3, + 7 + ] + }, + { + "input": [ + "BOS", + 24, + 16, + 26, + 26, + 9, + 27, + 27, + 15, + 14 + ], + "output": [ + "BOS", + 29, + 17, + 29, + 29, + 11, + 29, + 29, + 17, + 17 + ] + }, + { + "input": [ + "BOS", + 1, + 27, + 20, + 0, + 11, + 25, + 21, + 28, + 11 + ], + "output": [ + "BOS", + 2, + 29, + 23, + 2, + 11, + 29, + 23, + 29, + 11 + ] + }, + { + "input": [ + "BOS", + 23, + 2, + 21, + 20, + 1, + 23, + 11, + 29, + 5 + ], + "output": [ + "BOS", + 23, + 2, + 23, + 23, + 2, + 23, + 11, + 29, + 5 + ] + } + ], + "is_categorical": true + }, + "program": "return rasp.Map(next_prime, rasp.tokens).named(\"next_prime\")", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Maps each input number to the next prime number at or above it, producing a per-position replacement value." + }, + "rasp_vars": [ + "next_prime" + ], + "labels": [ + "map_1" + ] + } + ] +} diff --git a/annotations/case_106.json b/annotations/case_106.json new file mode 100644 index 0000000000000000000000000000000000000000..d35c2a0ca00c70fa90d8127eb07f83f868f517b3 --- /dev/null +++ b/annotations/case_106.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_106", + "name": "mask_sequence_index_1", + "summary": "Sets all elements to zero except for the element at index 1.", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 0, + 4, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 0, + 10, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 0, + 3, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + } + ], + "is_categorical": true + }, + "program": "return rasp.SequenceMap(lambda x, y: x if y == index else 0, rasp.tokens, rasp.indices)", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "COMBINER", + "note": "Combines token content with position information to keep only one chosen position." + }, + "rasp_vars": [ + "mask_sequence" + ], + "labels": [ + "sequence_map_1" + ] + } + ] +} diff --git a/annotations/case_11.json b/annotations/case_11.json new file mode 100644 index 0000000000000000000000000000000000000000..2463f3a1f0e0f8b1e73c5e9a901f293870204cf1 --- /dev/null +++ b/annotations/case_11.json @@ -0,0 +1,172 @@ +{ + "task": { + "id": "case_11", + "name": "word_count_by_length", + "summary": "Returns the length of each word in the input sequence.", + "examples": [ + { + "input": [ + "BOS", + "oCLrZaW", + "V", + "b", + "oCLrZaW", + "TPSI", + "poiVg", + "b", + "b", + "oCLrZaW" + ], + "output": [ + "BOS", + 7.0, + 1.0, + 1.0, + 7.0, + 4.0, + 5.0, + 1.0, + 1.0, + 7.0 + ] + }, + { + "input": [ + "BOS", + "LB", + "TPSI", + "oCLrZaW", + "TPSI", + "TPSI", + "poiVg", + "b", + "V", + "poiVg" + ], + "output": [ + "BOS", + 2.0, + 4.0, + 7.0, + 4.0, + 4.0, + 5.0, + 1.0, + 1.0, + 5.0 + ] + }, + { + "input": [ + "BOS", + "poiVg", + "TPSI", + "no", + "b", + "LB", + "poiVg", + "V", + "no", + "no" + ], + "output": [ + "BOS", + 5.0, + 4.0, + 2.0, + 1.0, + 2.0, + 5.0, + 1.0, + 2.0, + 2.0 + ] + }, + { + "input": [ + "BOS", + "V", + "J", + "J", + "TPSI", + "TPSI", + "oCLrZaW", + "LB", + "poiVg", + "V" + ], + "output": [ + "BOS", + 1.0, + 1.0, + 1.0, + 4.0, + 4.0, + 7.0, + 2.0, + 5.0, + 1.0 + ] + }, + { + "input": [ + "BOS", + "LB", + "poiVg", + "V", + "b", + "J", + "V", + "LB", + "no", + "b" + ], + "output": [ + "BOS", + 2.0, + 5.0, + 1.0, + 1.0, + 1.0, + 1.0, + 2.0, + 2.0, + 1.0 + ] + } + ], + "is_categorical": true + }, + "program": "word_length = rasp.Map(lambda x: len(x), sop)\nlength_selector = rasp.Select(word_length, word_length, rasp.Comparison.EQ)\nword_count = rasp.Aggregate(length_selector, word_length, default=None)\nreturn word_count", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Computes a per-token length feature that will be used to group tokens by equal length." + }, + "rasp_vars": [ + "word_length" + ], + "labels": [ + "map_3" + ] + }, + { + "id": "L1H0_ATTN", + "hook": "blocks.1.attn.hook_result[0]", + "role": { + "tag": "AGGREGATOR", + "note": "Groups positions by matching word length and aggregates to produce the per-length count-style output." + }, + "rasp_vars": [ + "length_selector", + "word_count" + ], + "labels": [ + "aggregate_1" + ] + } + ] +} diff --git a/annotations/case_110.json b/annotations/case_110.json new file mode 100644 index 0000000000000000000000000000000000000000..ff5c05bb3b14145c6cdb497f40748bd134cba23c --- /dev/null +++ b/annotations/case_110.json @@ -0,0 +1,172 @@ +{ + "task": { + "id": "case_110", + "name": "insert_zeros", + "summary": "Inserts zeros between each element, removing the latter half of the list.", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 2.0, + 0, + 4.0, + 0, + 2.0, + 0, + 6.0, + 0, + 4.0 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 4.0, + 0, + 1.0, + 0, + 7.0, + 0, + 5.0, + 0, + 1.0 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 10.0, + 0, + 10.0, + 0, + 7.0, + 0, + 4.0, + 0, + 3.0 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 8.0, + 0, + 0.0, + 0, + 10.0, + 0, + 10.0, + 0, + 9.0 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 6.0, + 0, + 3.0, + 0, + 10.0, + 0, + 7.0, + 0, + 4.0 + ] + } + ], + "is_categorical": true + }, + "program": "shifter = rasp.Select(rasp.indices, rasp.indices, lambda x, y: x == int(y / 2))\nshifted = rasp.Aggregate(shifter, rasp.tokens)\nreturn rasp.SequenceMap(lambda x, y: x if y % 2 == 0 else 0, shifted, rasp.indices)", + "components": [ + { + "id": "L0H0_ATTN", + "hook": "blocks.0.attn.hook_result[0]", + "role": { + "tag": "ROUTER", + "note": "Routes each output position to a source input position (floor(i/2)) so the first half gets expanded into even indices." + }, + "rasp_vars": [ + "shifter", + "shifted" + ], + "labels": [ + "aggregate_2" + ] + }, + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "COMBINER", + "note": "Uses the routed value and the position index to emit the value on even positions and 0 on odd positions." + }, + "rasp_vars": [ + "sequence_map" + ], + "labels": [ + "sequence_map_1" + ] + } + ] +} diff --git a/annotations/case_111.json b/annotations/case_111.json new file mode 100644 index 0000000000000000000000000000000000000000..b4944b4c8a3eea83861e17a7cadd643abd3e5b99 --- /dev/null +++ b/annotations/case_111.json @@ -0,0 +1,214 @@ +{ + "task": { + "id": "case_111", + "name": "last_element_with_zero_padding", + "summary": "Returns the last element of the sequence and pads the rest with zeros.", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 3.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 5.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 5.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 8.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 6.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + } + ], + "is_categorical": true + }, + "program": "length = rasp.SelectorWidth(rasp.Select(rasp.tokens, rasp.tokens, rasp.Comparison.TRUE)).named(\"length\")\nlast_element_selector = rasp.Select(rasp.indices, rasp.Map(lambda x: x - 1, length), rasp.Comparison.EQ).named(\"last_element_selector\")\nlast_element_sequence = rasp.Aggregate(last_element_selector, rasp.tokens).named(\"last_element_sequence\")\nreturn rasp.SequenceMap(lambda x, y: x if y == 0 else 0, last_element_sequence, rasp.indices)", + "components": [ + { + "id": "L0H0_ATTN", + "hook": "blocks.0.attn.hook_result[0]", + "role": { + "tag": "AGGREGATOR", + "note": "Produces a shared sequence length signal used to identify the last position." + }, + "rasp_vars": [ + "length" + ], + "labels": [ + "length_5_selector_width_attn_output" + ] + }, + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Turns the length-related signal into a sequence-length feature." + }, + "rasp_vars": [ + "length" + ], + "labels": [ + "length_5", + "length_5_selector_width_attn_output" + ] + }, + { + "id": "L1_MLP", + "hook": "blocks.1.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Computes the last element's index by applying element-wise subtraction to the sequence-length feature." + }, + "rasp_vars": [ + "last_index" + ], + "labels": [ + "map_4" + ] + }, + { + "id": "L2H0_ATTN", + "hook": "blocks.2.attn.hook_result[0]", + "role": { + "tag": "ROUTER", + "note": "Retrieves the last token and makes it available for placement into the output sequence." + }, + "rasp_vars": [ + "last_element_sequence" + ], + "labels": [ + "last_element_sequence_2" + ] + }, + { + "id": "L2_MLP", + "hook": "blocks.2.mlp.hook_post", + "role": { + "tag": "COMBINER", + "note": "Outputs the last token in the first slot and writes zeros in every other slot." + }, + "rasp_vars": [ + "output_sequence" + ], + "labels": [ + "sequence_map_1" + ] + } + ] +} diff --git a/annotations/case_113.json b/annotations/case_113.json new file mode 100644 index 0000000000000000000000000000000000000000..e799c211485285e85cfc4d858c2af1da6cf4ec51 --- /dev/null +++ b/annotations/case_113.json @@ -0,0 +1,291 @@ +{ + "task": { + "id": "case_113", + "name": "invert_if_sorted", + "summary": "Inverts the sequence if it is sorted in ascending order, otherwise leaves it unchanged.", + "examples": [ + { + "input": [ + "BOS", + 6, + 19, + 28, + 14, + 10, + 7, + 28, + 20, + 6 + ], + "output": [ + "BOS", + 6.0, + 19.0, + 28.0, + 14.0, + 10.0, + 7.0, + 28.0, + 20.0, + 6.0 + ] + }, + { + "input": [ + "BOS", + 25, + 18, + 22, + 10, + 10, + 23, + 20, + 3, + 7 + ], + "output": [ + "BOS", + 25.0, + 18.0, + 22.0, + 10.0, + 10.0, + 23.0, + 20.0, + 3.0, + 7.0 + ] + }, + { + "input": [ + "BOS", + 24, + 16, + 26, + 26, + 9, + 27, + 27, + 15, + 14 + ], + "output": [ + "BOS", + 24.0, + 16.0, + 26.0, + 26.0, + 9.0, + 27.0, + 27.0, + 15.0, + 14.0 + ] + }, + { + "input": [ + "BOS", + 1, + 27, + 20, + 0, + 11, + 25, + 21, + 28, + 11 + ], + "output": [ + "BOS", + 1.0, + 27.0, + 20.0, + 0.0, + 11.0, + 25.0, + 21.0, + 28.0, + 11.0 + ] + }, + { + "input": [ + "BOS", + 23, + 2, + 21, + 20, + 1, + 23, + 11, + 29, + 5 + ], + "output": [ + "BOS", + 23.0, + 2.0, + 21.0, + 20.0, + 1.0, + 23.0, + 11.0, + 29.0, + 5.0 + ] + } + ], + "is_categorical": true + }, + "program": "shifter = rasp.Select(rasp.indices, rasp.indices, lambda x, y: x == y - 1 or (x == 0 and y == 0))\nshifted = rasp.Aggregate(shifter, rasp.tokens)\nchecks = rasp.SequenceMap(lambda x, y: 1 if x <= y else 0, shifted, rasp.tokens)\nzero_selector = rasp.Select(checks, rasp.Map(lambda x: 0, rasp.indices), rasp.Comparison.EQ)\ninvert_decider = rasp.Map(lambda x: 1 if x > 0 else -1, rasp.SelectorWidth(zero_selector))\navg_idx = rasp.Map(lambda x: x / 2 - 0.5, rasp.SelectorWidth(rasp.Select(rasp.indices, rasp.indices, rasp.Comparison.TRUE)))\ndiff_to_avg_idx = rasp.SequenceMap(lambda x, y: x - y, rasp.indices, avg_idx)\ninverter = rasp.SequenceMap(lambda x, y: x + y, avg_idx, rasp.SequenceMap(lambda x, y: x * y, invert_decider, diff_to_avg_idx))\ninvert_selector = rasp.Select(inverter, rasp.indices, rasp.Comparison.EQ)\nreturn rasp.Aggregate(invert_selector, rasp.tokens)", + "components": [ + { + "id": "L0H0_ATTN", + "hook": "blocks.0.attn.hook_result[0]", + "role": { + "tag": "AGGREGATOR", + "note": "Counts the number of non-increasing steps in the sequence by attending over positions where the sortedness check fails" + }, + "rasp_vars": [ + "shifter" + ], + "labels": [ + "selector_width_6_selector_width_attn_output" + ] + }, + { + "id": "L0H1_ATTN", + "hook": "blocks.0.attn.hook_result[1]", + "role": { + "tag": "ROUTER", + "note": "Produces the shifted token stream that aligns each token with its predecessor." + }, + "rasp_vars": [ + "shifted" + ], + "labels": [ + "aggregate_14" + ] + }, + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Converts the attention-derived selector-width signal into sortedness evidence used by the global invert/keep decision." + }, + "rasp_vars": [ + "checks", + "zero_selector" + ], + "labels": [ + "selector_width_6", + "selector_width_6_selector_width_attn_output", + "map_13" + ] + }, + { + "id": "L1_MLP", + "hook": "blocks.1.mlp.hook_post", + "role": { + "tag": "COMBINER", + "note": "Converts the sortedness evidence into a single invert/keep control signal for the rest of the circuit." + }, + "rasp_vars": [ + "checks", + "invert_decider" + ], + "labels": [ + "map_4", + "sequence_map_12" + ] + }, + { + "id": "L2H0_ATTN", + "hook": "blocks.2.attn.hook_result[0]", + "role": { + "tag": "AGGREGATOR", + "note": "Provides the sequence-length-style signal that is later turned into a center index reference for inversion." + }, + "rasp_vars": [ + "length_helper" + ], + "labels": [ + "selector_width_10_selector_width_attn_output" + ] + }, + { + "id": "L2_MLP", + "hook": "blocks.2.mlp.hook_post", + "role": { + "tag": "COMBINER", + "note": "Turns the length/position information into a center reference and a per-position offset-from-center signal used for inversion arithmetic." + }, + "rasp_vars": [ + "avg_idx", + "diff_to_avg_idx" + ], + "labels": [ + "selector_width_10", + "selector_width_10_selector_width_attn_output", + "sequence_map_8" + ] + }, + { + "id": "L3_MLP", + "hook": "blocks.3.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Prepares an intermediate numeric signal for building the inverted index mapping." + }, + "rasp_vars": [ + "inversion_prep" + ], + "labels": [ + "map_7" + ] + }, + { + "id": "L4_MLP", + "hook": "blocks.4.mlp.hook_post", + "role": { + "tag": "COMBINER", + "note": "Combines the center reference, per-position offset, and the invert/keep control to produce the target source index for each position." + }, + "rasp_vars": [ + "inverter" + ], + "labels": [ + "sequence_map_5" + ] + }, + { + "id": "L5_MLP", + "hook": "blocks.5.mlp.hook_post", + "role": { + "tag": "COMBINER", + "note": "Finalizes the per-position index routing plan that will be used to either invert the sequence or leave it unchanged." + }, + "rasp_vars": [ + "invert_selector" + ], + "labels": [ + "sequence_map_3" + ] + }, + { + "id": "L6H0_ATTN", + "hook": "blocks.6.attn.hook_result[0]", + "role": { + "tag": "ROUTER", + "note": "Executes the final token movement: each position copies from its computed source index, yielding either the inverted or original sequence." + }, + "rasp_vars": [ + "output" + ], + "labels": [ + "aggregate_1" + ] + } + ] +} diff --git a/annotations/case_114.json b/annotations/case_114.json new file mode 100644 index 0000000000000000000000000000000000000000..7b5c178c2c0c25c50f3901ca7260eb73e0a8d068 --- /dev/null +++ b/annotations/case_114.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_114", + "name": "logarithm_base10", + "summary": "Apply a logarithm base 10 to each element of the input sequence.", + "examples": [ + { + "input": [ + "BOS", + 7, + 4, + 8, + 5, + 7, + 10, + 3, + 7, + 8 + ], + "output": [ + "BOS", + 0.8450980400142567, + 0.6020599913279623, + 0.9030899869919434, + 0.6989700043360187, + 0.8450980400142567, + 1.0, + 0.47712125471966244, + 0.8450980400142567, + 0.9030899869919434 + ] + }, + { + "input": [ + "BOS", + 3, + 7, + 4, + 9, + 3, + 5, + 3, + 7, + 5 + ], + "output": [ + "BOS", + 0.47712125471966244, + 0.8450980400142567, + 0.6020599913279623, + 0.9542425094393249, + 0.47712125471966244, + 0.6989700043360187, + 0.47712125471966244, + 0.8450980400142567, + 0.6989700043360187 + ] + }, + { + "input": [ + "BOS", + 6, + 2, + 5, + 1, + 10, + 6, + 9, + 1, + 10 + ], + "output": [ + "BOS", + 0.7781512503836435, + 0.30102999566398114, + 0.6989700043360187, + 0.0, + 1.0, + 0.7781512503836435, + 0.9542425094393249, + 0.0, + 1.0 + ] + }, + { + "input": [ + "BOS", + 5, + 4, + 8, + 8, + 3, + 6, + 5, + 2, + 8 + ], + "output": [ + "BOS", + 0.6989700043360187, + 0.6020599913279623, + 0.9030899869919434, + 0.9030899869919434, + 0.47712125471966244, + 0.7781512503836435, + 0.6989700043360187, + 0.30102999566398114, + 0.9030899869919434 + ] + }, + { + "input": [ + "BOS", + 9, + 7, + 2, + 4, + 9, + 2, + 10, + 9, + 10 + ], + "output": [ + "BOS", + 0.9542425094393249, + 0.8450980400142567, + 0.30102999566398114, + 0.6020599913279623, + 0.9542425094393249, + 0.30102999566398114, + 1.0, + 0.9542425094393249, + 1.0 + ] + } + ], + "is_categorical": true + }, + "program": "def apply_log(element):\n return math.log(element, 10)\n\nlogarithm = rasp.Map(apply_log, rasp.tokens).named(\"logarithm\")\nreturn logarithm", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Applies a base-10 logarithm to each element independently." + }, + "rasp_vars": [ + "logarithm" + ], + "labels": [ + "logarithm_1" + ] + } + ] +} diff --git a/annotations/case_121.json b/annotations/case_121.json new file mode 100644 index 0000000000000000000000000000000000000000..ea14266b685fe3ea55b002f56359a3a58c15aa93 --- /dev/null +++ b/annotations/case_121.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_121", + "name": "arcsine", + "summary": "Applies the arcsine function to each element.", + "examples": [ + { + "input": [ + "BOS", + 0.7, + -0.19999999999999996, + -0.9, + 0.8999999999999999, + 0.3999999999999999, + -0.4, + 0.10000000000000009, + -0.30000000000000004, + 0.3999999999999999 + ], + "output": [ + "BOS", + 0.775397496610753, + -0.20135792079033074, + -1.1197695149986342, + 1.119769514998634, + 0.4115168460674879, + -0.41151684606748806, + 0.10016742116155988, + -0.3046926540153976, + 0.4115168460674879 + ] + }, + { + "input": [ + "BOS", + -0.8, + -0.6, + 0.8, + -0.4, + -0.19999999999999996, + -0.4, + 0.7, + -0.7, + 0.30000000000000004 + ], + "output": [ + "BOS", + -0.9272952180016123, + -0.6435011087932844, + 0.9272952180016123, + -0.41151684606748806, + -0.20135792079033074, + -0.41151684606748806, + 0.775397496610753, + -0.775397496610753, + 0.3046926540153976 + ] + }, + { + "input": [ + "BOS", + -0.4, + 0.8999999999999999, + 0.3999999999999999, + 0.0, + -0.30000000000000004, + -0.4, + 0.8, + 0.0, + 0.0 + ], + "output": [ + "BOS", + -0.41151684606748806, + 1.119769514998634, + 0.4115168460674879, + 0.0, + -0.3046926540153976, + -0.41151684606748806, + 0.9272952180016123, + 0.0, + 0.0 + ] + }, + { + "input": [ + "BOS", + -0.7, + -0.30000000000000004, + -0.8, + -0.9, + 0.10000000000000009, + -0.5, + -0.9, + -1.0, + 0.10000000000000009 + ], + "output": [ + "BOS", + -0.775397496610753, + -0.3046926540153976, + -0.9272952180016123, + -1.1197695149986342, + 0.10016742116155988, + -0.5235987755982989, + -1.1197695149986342, + -1.5707963267948966, + 0.10016742116155988 + ] + }, + { + "input": [ + "BOS", + 0.10000000000000009, + 0.6000000000000001, + -0.09999999999999998, + 0.5, + 0.3999999999999999, + 0.3999999999999999, + 0.8, + 0.10000000000000009, + 0.8999999999999999 + ], + "output": [ + "BOS", + 0.10016742116155988, + 0.6435011087932845, + -0.10016742116155977, + 0.5235987755982989, + 0.4115168460674879, + 0.4115168460674879, + 0.9272952180016123, + 0.10016742116155988, + 1.119769514998634 + ] + } + ], + "is_categorical": true + }, + "program": "return rasp.Map(lambda x: math.asin(x), rasp.tokens)", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Applies an arcsine nonlinear transformation to each input element independently." + }, + "rasp_vars": [ + "arcsine" + ], + "labels": [ + "map_1" + ] + } + ] +} diff --git a/annotations/case_122.json b/annotations/case_122.json new file mode 100644 index 0000000000000000000000000000000000000000..4e4e2b2a22614207c8162b05ab2d7c00008fd437 --- /dev/null +++ b/annotations/case_122.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_122", + "name": "check_divisible_by_3", + "summary": "Check if each number is divisible by 3.", + "examples": [ + { + "input": [ + "BOS", + 6, + 19, + 28, + 14, + 10, + 7, + 28, + 20, + 6 + ], + "output": [ + "BOS", + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1 + ] + }, + { + "input": [ + "BOS", + 25, + 18, + 22, + 10, + 10, + 23, + 20, + 3, + 7 + ], + "output": [ + "BOS", + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 1, + 0 + ] + }, + { + "input": [ + "BOS", + 24, + 16, + 26, + 26, + 9, + 27, + 27, + 15, + 14 + ], + "output": [ + "BOS", + 1, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 0 + ] + }, + { + "input": [ + "BOS", + 1, + 27, + 20, + 0, + 11, + 25, + 21, + 28, + 11 + ], + "output": [ + "BOS", + 0, + 1, + 0, + 1, + 0, + 0, + 1, + 0, + 0 + ] + }, + { + "input": [ + "BOS", + 23, + 2, + 21, + 20, + 1, + 23, + 11, + 29, + 5 + ], + "output": [ + "BOS", + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0 + ] + } + ], + "is_categorical": true + }, + "program": "check_divisible_by_3 = rasp.Map(lambda x: 1 if x % 3 == 0 else 0, rasp.tokens).named(\"check_divisible_by_3\")\nreturn check_divisible_by_3", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "INDICATOR", + "note": "Outputs 1 when the input number is divisible by 3, otherwise outputs 0." + }, + "rasp_vars": [ + "check_divisible_by_3" + ], + "labels": [ + "map_1" + ] + } + ] +} diff --git a/annotations/case_123.json b/annotations/case_123.json new file mode 100644 index 0000000000000000000000000000000000000000..c6fddf3afa909389814a61c9b5e21f90790922d2 --- /dev/null +++ b/annotations/case_123.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_123", + "name": "arccosine", + "summary": "Apply arccosine to each element of the input sequence.", + "examples": [ + { + "input": [ + "BOS", + 0.7, + -0.19999999999999996, + -0.9, + 0.8999999999999999, + 0.3999999999999999, + -0.4, + 0.10000000000000009, + -0.30000000000000004, + 0.3999999999999999 + ], + "output": [ + "BOS", + 0.7953988301841436, + 1.7721542475852274, + 2.6905658417935308, + 0.45102681179626264, + 1.1592794807274087, + 1.9823131728623846, + 1.4706289056333368, + 1.8754889808102941, + 1.1592794807274087 + ] + }, + { + "input": [ + "BOS", + -0.8, + -0.6, + 0.8, + -0.4, + -0.19999999999999996, + -0.4, + 0.7, + -0.7, + 0.30000000000000004 + ], + "output": [ + "BOS", + 2.498091544796509, + 2.214297435588181, + 0.6435011087932843, + 1.9823131728623846, + 1.7721542475852274, + 1.9823131728623846, + 0.7953988301841436, + 2.3461938234056494, + 1.266103672779499 + ] + }, + { + "input": [ + "BOS", + -0.4, + 0.8999999999999999, + 0.3999999999999999, + 0.0, + -0.30000000000000004, + -0.4, + 0.8, + 0.0, + 0.0 + ], + "output": [ + "BOS", + 1.9823131728623846, + 0.45102681179626264, + 1.1592794807274087, + 1.5707963267948966, + 1.8754889808102941, + 1.9823131728623846, + 0.6435011087932843, + 1.5707963267948966, + 1.5707963267948966 + ] + }, + { + "input": [ + "BOS", + -0.7, + -0.30000000000000004, + -0.8, + -0.9, + 0.10000000000000009, + -0.5, + -0.9, + -1.0, + 0.10000000000000009 + ], + "output": [ + "BOS", + 2.3461938234056494, + 1.8754889808102941, + 2.498091544796509, + 2.6905658417935308, + 1.4706289056333368, + 2.0943951023931957, + 2.6905658417935308, + 3.141592653589793, + 1.4706289056333368 + ] + }, + { + "input": [ + "BOS", + 0.10000000000000009, + 0.6000000000000001, + -0.09999999999999998, + 0.5, + 0.3999999999999999, + 0.3999999999999999, + 0.8, + 0.10000000000000009, + 0.8999999999999999 + ], + "output": [ + "BOS", + 1.4706289056333368, + 0.9272952180016121, + 1.6709637479564563, + 1.0471975511965979, + 1.1592794807274087, + 1.1592794807274087, + 0.6435011087932843, + 1.4706289056333368, + 0.45102681179626264 + ] + } + ], + "is_categorical": true + }, + "program": "return rasp.Map(lambda x: math.acos(x), rasp.tokens)", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Applies an arccosine nonlinear transformation to each input element independently." + }, + "rasp_vars": [ + "arccosine" + ], + "labels": [ + "map_1" + ] + } + ] +} diff --git a/annotations/case_124.json b/annotations/case_124.json new file mode 100644 index 0000000000000000000000000000000000000000..b83f973a5d1dc56a13c0c4af5470f4dd0fd1c3cf --- /dev/null +++ b/annotations/case_124.json @@ -0,0 +1,216 @@ +{ + "task": { + "id": "case_124", + "name": "check_all_equal", + "summary": "Check if all elements in a list are equal.", + "examples": [ + { + "input": [ + "BOS", + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3 + ], + "output": [ + "BOS", + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ] + }, + { + "input": [ + "BOS", + 9, + 4, + 0, + 2, + 5, + 3, + 7, + 10, + 8 + ], + "output": [ + "BOS", + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + }, + { + "input": [ + "BOS", + 2, + 1, + 8, + 9, + 4, + 3, + 0, + 6, + 5 + ], + "output": [ + "BOS", + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + }, + { + "input": [ + "BOS", + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "output": [ + "BOS", + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ] + }, + { + "input": [ + "BOS", + 3, + 8, + 0, + 10, + 5, + 6, + 4, + 7, + 9 + ], + "output": [ + "BOS", + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + } + ], + "is_categorical": true + }, + "program": "unequal_selector = rasp.Select(rasp.tokens, rasp.tokens, lambda x, y: x != y)\nchecks = rasp.SelectorWidth(unequal_selector)\nzero_selector = rasp.Select(checks, rasp.Map(lambda x: 0, rasp.indices), rasp.Comparison.EQ)\nreturn rasp.Map(lambda x: 1 if x > 0 else 0, rasp.SelectorWidth(zero_selector))", + "components": [ + { + "id": "L0H0_ATTN", + "hook": "blocks.0.attn.hook_result[0]", + "role": { + "tag": "AGGREGATOR", + "note": "Aggregates positions holding tokens unequal to the current token into a per-position mismatch count." + }, + "rasp_vars": [ + "unequal_selector" + ], + "labels": [ + "selector_width_4_selector_width_attn_output" + ] + }, + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Turns the mismatch signal into a per-position mismatch count and prepares it for the global decision." + }, + "rasp_vars": [ + "checks" + ], + "labels": [ + "selector_width_4", + "map_5", + "selector_width_4_selector_width_attn_output" + ] + }, + { + "id": "L1H0_ATTN", + "hook": "blocks.1.attn.hook_result[0]", + "role": { + "tag": "AGGREGATOR", + "note": "Aggregates positions where the mismatch count is zero, producing a per-position count of zero-mismatch occurrences." + }, + "rasp_vars": [ + "zero_selector" + ], + "labels": [ + "selector_width_2_selector_width_attn_output" + ] + }, + { + "id": "L1_MLP", + "hook": "blocks.1.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Converts the zero-mismatch mask into a scalar-like summary signal that can be read out." + }, + "rasp_vars": [ + "all_equal_signal" + ], + "labels": [ + "selector_width_2", + "selector_width_2_selector_width_attn_output" + ] + }, + { + "id": "L2_MLP", + "hook": "blocks.2.mlp.hook_post", + "role": { + "tag": "INDICATOR", + "note": "Outputs the final binary decision: 1 if all elements are equal, otherwise 0." + }, + "rasp_vars": [ + "all_equal" + ], + "labels": [ + "map_1" + ] + } + ] +} diff --git a/annotations/case_129.json b/annotations/case_129.json new file mode 100644 index 0000000000000000000000000000000000000000..73914b8de9a263f64ccb288d9881650a771d0f82 --- /dev/null +++ b/annotations/case_129.json @@ -0,0 +1,200 @@ +{ + "task": { + "id": "case_129", + "name": "check_multiple_of_n", + "summary": "Checks if all elements are a multiple of n (default n=2).", + "examples": [ + { + "input": [ + "BOS", + 0, + 28, + 2, + 6, + 22, + 16, + 26, + 20, + 10 + ], + "output": [ + "BOS", + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ] + }, + { + "input": [ + "BOS", + 0, + 8, + 2, + 26, + 9, + 6, + 20, + 24, + 12 + ], + "output": [ + "BOS", + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + }, + { + "input": [ + "BOS", + 4, + 10, + 14, + 0, + 6, + 9, + 12, + 8, + 18 + ], + "output": [ + "BOS", + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + }, + { + "input": [ + "BOS", + 0, + 22, + 8, + 6, + 26, + 4, + 2, + 16, + 24 + ], + "output": [ + "BOS", + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ] + }, + { + "input": [ + "BOS", + 2, + 26, + 8, + 14, + 29, + 18, + 0, + 10, + 16 + ], + "output": [ + "BOS", + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + } + ], + "is_categorical": true + }, + "program": "checks = rasp.Map(lambda x: 1 if x % n == 0 else 0, rasp.tokens).named(f\"check_multiple_of_{n}\")\nzero_selector = rasp.Select(checks, rasp.Map(lambda x: 0, rasp.indices), rasp.Comparison.EQ)\nreturn rasp.Map(lambda x: 0 if x > 0 else 1, rasp.SelectorWidth(zero_selector))", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "INDICATOR", + "note": "Computes a per-element pass/fail flag indicating whether each value is divisible by n." + }, + "rasp_vars": [ + "checks" + ], + "labels": [ + "check_multiple_of_2_4", + "map_5" + ] + }, + { + "id": "L1H0_ATTN", + "hook": "blocks.1.attn.hook_result[0]", + "role": { + "tag": "AGGREGATOR", + "note": "Aggregates positions where the divisibility flag is zero, producing a per-position count of non-multiple occurrences." + }, + "rasp_vars": [ + "zero_selector" + ], + "labels": [ + "selector_width_2_selector_width_attn_output" + ] + }, + { + "id": "L1_MLP", + "hook": "blocks.1.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Summarizes the mismatch count signal into a single global indicator shared across positions." + }, + "rasp_vars": [ + "mismatch_count" + ], + "labels": [ + "selector_width_2" + ] + }, + { + "id": "L2_MLP", + "hook": "blocks.2.mlp.hook_post", + "role": { + "tag": "INDICATOR", + "note": "Converts the global mismatch indicator into the final decision: all-multiples vs not-all-multiples." + }, + "rasp_vars": [ + "all_multiples" + ], + "labels": [ + "map_1" + ] + } + ] +} diff --git a/annotations/case_13.json b/annotations/case_13.json new file mode 100644 index 0000000000000000000000000000000000000000..79de594890e2686dc187bbec930e4929b9ef216e --- /dev/null +++ b/annotations/case_13.json @@ -0,0 +1,171 @@ +{ + "task": { + "id": "case_13", + "name": "token_trend_analysis", + "summary": "Analyzes the trend [increasing, decreasing, constant] of numeric tokens.", + "examples": [ + { + "input": [ + "BOS", + 1, + 1, + 0, + 0, + 1, + 1, + 0, + 0, + 0 + ], + "output": [ + "BOS", + "constant", + "decreasing", + "constant", + "increasing", + "constant", + "decreasing", + "constant", + "constant", + null + ] + }, + { + "input": [ + "BOS", + 2, + 2, + 0, + 2, + 0, + 2, + 2, + 0, + 0 + ], + "output": [ + "BOS", + "constant", + "decreasing", + "increasing", + "decreasing", + "increasing", + "constant", + "decreasing", + "constant", + null + ] + }, + { + "input": [ + "BOS", + 2, + 0, + 2, + 2, + 0, + 0, + 2, + 1, + 2 + ], + "output": [ + "BOS", + "decreasing", + "increasing", + "constant", + "decreasing", + "constant", + "increasing", + "decreasing", + "increasing", + null + ] + }, + { + "input": [ + "BOS", + 2, + 2, + 2, + 1, + 2, + 1, + 1, + 2, + 1 + ], + "output": [ + "BOS", + "constant", + "constant", + "decreasing", + "increasing", + "decreasing", + "constant", + "increasing", + "decreasing", + null + ] + }, + { + "input": [ + "BOS", + 2, + 2, + 2, + 0, + 2, + 1, + 0, + 1, + 1 + ], + "output": [ + "BOS", + "constant", + "constant", + "decreasing", + "increasing", + "decreasing", + "decreasing", + "increasing", + "constant", + null + ] + } + ], + "is_categorical": true + }, + "program": "select_off_by_offset = rasp.Select[rasp.indices, rasp.indices, lambda k,q: q == k + offset]\nnext_token = rasp.Aggregate[select_off_by_offset, sop, default=None].named[\"shift_by(-1)\"]\ntrend_analysis = rasp.SequenceMap[second_part_fn, sop, next_token]\nreturn trend_analysis", + "components": [ + { + "id": "L0H0_ATTN", + "hook": "blocks.0.attn.hook_result[0]", + "role": { + "tag": "ROUTER", + "note": "Shifts the sequence to provide each position with the next token (and pads the end)." + }, + "rasp_vars": [ + "next_token" + ], + "labels": [ + "shift_by(-1)_2" + ] + }, + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "COMBINER", + "note": "Compares the current token with the next token and outputs the trend class." + }, + "rasp_vars": [ + "trend_analysis" + ], + "labels": [ + "sequence_map_1" + ] + } + ] +} diff --git a/annotations/case_130.json b/annotations/case_130.json new file mode 100644 index 0000000000000000000000000000000000000000..6101f777db6eb0b7756fc68af9104de3e5b15d40 --- /dev/null +++ b/annotations/case_130.json @@ -0,0 +1,187 @@ +{ + "task": { + "id": "case_130", + "name": "clip", + "summary": "Clips each element to be within a range (make the default range [2, 7]).", + "examples": [ + { + "input": [ + "BOS", + -9, + 4, + 13, + -1, + -5, + -8, + 13, + 5, + -9 + ], + "output": [ + "BOS", + 2, + 4, + 7, + 2, + 2, + 2, + 7, + 5, + 2 + ] + }, + { + "input": [ + "BOS", + 10, + 3, + 7, + -5, + -5, + 8, + 5, + -12, + -8 + ], + "output": [ + "BOS", + 7, + 3, + 7, + 2, + 2, + 7, + 5, + 2, + 2 + ] + }, + { + "input": [ + "BOS", + 9, + 1, + 11, + 11, + -6, + 12, + 12, + 0, + -1 + ], + "output": [ + "BOS", + 7, + 2, + 7, + 7, + 2, + 7, + 7, + 2, + 2 + ] + }, + { + "input": [ + "BOS", + -14, + 12, + 5, + -15, + -4, + 10, + 6, + 13, + -4 + ], + "output": [ + "BOS", + 2, + 7, + 5, + 2, + 2, + 7, + 6, + 7, + 2 + ] + }, + { + "input": [ + "BOS", + 8, + -13, + 6, + 5, + -14, + 8, + -4, + 14, + -10 + ], + "output": [ + "BOS", + 7, + 2, + 6, + 5, + 2, + 7, + 2, + 7, + 2 + ] + } + ], + "is_categorical": true + }, + "program": "all_min_val = rasp.Map(lambda x: 2, rasp.tokens)\nall_max_val = rasp.Map(lambda x: 7, rasp.tokens)\nless_than_min = rasp.Map(lambda x: x < 2, rasp.tokens)\ngreater_than_max = rasp.Map(lambda x: x > 7, rasp.tokens)\nclip_min = rasp.SequenceMap(lambda orig, clip: clip if orig < 2 else orig, rasp.tokens, all_min_val)\nclip_max = rasp.SequenceMap(lambda clipped_min, clip: clip if clipped_min > 7 else clipped_min, clip_min, all_max_val)\nreturn clip_max", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Creates constant per-position helper values used as the lower and upper clipping bounds." + }, + "rasp_vars": [ + "all_min_val", + "all_max_val" + ], + "labels": [ + "map_3", + "map_4" + ] + }, + { + "id": "L1_MLP", + "hook": "blocks.1.mlp.hook_post", + "role": { + "tag": "COMBINER", + "note": "Applies the lower-bound clipping step, replacing values below the minimum with the minimum." + }, + "rasp_vars": [ + "clip_min" + ], + "labels": [ + "sequence_map_2" + ] + }, + { + "id": "L2_MLP", + "hook": "blocks.2.mlp.hook_post", + "role": { + "tag": "COMBINER", + "note": "Applies the upper-bound clipping step, replacing values above the maximum with the maximum." + }, + "rasp_vars": [ + "clip_max" + ], + "labels": [ + "sequence_map_1" + ] + } + ] +} diff --git a/annotations/case_14.json b/annotations/case_14.json new file mode 100644 index 0000000000000000000000000000000000000000..6ae7ed17686ac23b73f0a08b08f24b1a03165211 --- /dev/null +++ b/annotations/case_14.json @@ -0,0 +1,171 @@ +{ + "task": { + "id": "case_14", + "name": "count_a", + "summary": "Returns the count of 'a' in the input sequence.", + "examples": [ + { + "input": [ + "BOS", + "b", + "b", + "a", + "a", + "b", + "b", + "a", + "a", + "a" + ], + "output": [ + "BOS", + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5 + ] + }, + { + "input": [ + "BOS", + "c", + "c", + "a", + "c", + "a", + "c", + "c", + "a", + "a" + ], + "output": [ + "BOS", + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 4 + ] + }, + { + "input": [ + "BOS", + "c", + "a", + "c", + "c", + "a", + "a", + "c", + "b", + "c" + ], + "output": [ + "BOS", + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3 + ] + }, + { + "input": [ + "BOS", + "c", + "c", + "c", + "b", + "c", + "b", + "b", + "c", + "b" + ], + "output": [ + "BOS", + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + }, + { + "input": [ + "BOS", + "c", + "c", + "c", + "a", + "c", + "b", + "a", + "b", + "b" + ], + "output": [ + "BOS", + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2 + ] + } + ], + "is_categorical": true + }, + "program": "count_a_selector = rasp.Select(sop, sop, lambda k, q: k == token).named(\"count_a_selector\")\ncount_a = rasp.SelectorWidth(count_a_selector).named(\"count_a\")\nreturn count_a", + "components": [ + { + "id": "L0H0_ATTN", + "hook": "blocks.0.attn.hook_result[0]", + "role": { + "tag": "AGGREGATOR", + "note": "Aggregates positions containing the target token 'a' into a per-position match count." + }, + "rasp_vars": [ + "count_a_selector" + ], + "labels": [ + "count_a_1_selector_width_attn_output" + ] + }, + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Turns the match pattern into a per-position total count of 'a' in the sequence." + }, + "rasp_vars": [ + "count_a" + ], + "labels": [ + "count_a_1" + ] + } + ] +} diff --git a/annotations/case_15.json b/annotations/case_15.json new file mode 100644 index 0000000000000000000000000000000000000000..2ee9c344c784cbbb3c2625a1756939a556679b06 --- /dev/null +++ b/annotations/case_15.json @@ -0,0 +1,135 @@ +{ + "task": { + "id": "case_15", + "name": "double_minus_index", + "summary": "Returns each token multiplied by two and subtracted by its index.", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 3, + 2 + ], + "output": [ + "BOS", + 4, + 7, + 4, + 1 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 3, + 1 + ], + "output": [ + "BOS", + 8, + 1, + 4, + -1 + ] + }, + { + "input": [ + "BOS", + 3, + 4, + 2, + 4 + ], + "output": [ + "BOS", + 6, + 7, + 2, + 5 + ] + }, + { + "input": [ + "BOS", + 3, + 4, + 0, + 3 + ], + "output": [ + "BOS", + 6, + 7, + -2, + 3 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 2, + 2 + ], + "output": [ + "BOS", + 8, + 1, + 2, + 1 + ] + } + ], + "is_categorical": true + }, + "program": "values, *sops = sops; for sop in sops: values = rasp.SequenceMap(lambda x, y: (*x, y) if isinstance(x, tuple) else (x, y), values, sop); return rasp.Map(lambda args: f(*args), values)", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "COMBINER", + "note": "Builds an intermediate representation that packages multiple per-position inputs together so they can be processed as a single combined object downstream." + }, + "rasp_vars": [ + "values_tuple_stage_1" + ], + "labels": [ + "sequence_map_3" + ] + }, + { + "id": "L1_MLP", + "hook": "blocks.1.mlp.hook_post", + "role": { + "tag": "COMBINER", + "note": "Extends the combined per-position representation by incorporating the position index, forming the final set of arguments needed for the arithmetic step." + }, + "rasp_vars": [ + "values_tuple_stage_2" + ], + "labels": [ + "sequence_map_2" + ] + }, + { + "id": "L2_MLP", + "hook": "blocks.2.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Computes the final per-position arithmetic from the bundled arguments (equivalent to doubling the token value and subtracting the index)." + }, + "rasp_vars": [ + "output" + ], + "labels": [ + "map_1" + ] + } + ] +} diff --git a/annotations/case_18.json b/annotations/case_18.json new file mode 100644 index 0000000000000000000000000000000000000000..9662227699addb9ffa70d2ee9f49ae118180a12a --- /dev/null +++ b/annotations/case_18.json @@ -0,0 +1,203 @@ +{ + "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" + ] + } + ] +} diff --git a/annotations/case_19.json b/annotations/case_19.json new file mode 100644 index 0000000000000000000000000000000000000000..5d7adc8d8f0f39fe3ccb81771a01aad225f8a87e --- /dev/null +++ b/annotations/case_19.json @@ -0,0 +1,221 @@ +{ + "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" + ] + } + ] +} diff --git a/annotations/case_2.json b/annotations/case_2.json new file mode 100644 index 0000000000000000000000000000000000000000..7ab9bc15bc0ad610a72b6983f3fe612c814ea3d6 --- /dev/null +++ b/annotations/case_2.json @@ -0,0 +1,215 @@ +{ + "task": { + "id": "case_2", + "name": "reverse_sequence", + "summary": "Reverse the input sequence.", + "examples": [ + { + "input": [ + "BOS", + "l", + "z", + "v", + "l", + "y", + "q", + "j", + "p", + "o" + ], + "output": [ + "BOS", + "o", + "p", + "j", + "q", + "y", + "l", + "v", + "z", + "l" + ] + }, + { + "input": [ + "BOS", + "w", + "k", + "k", + "x", + "u", + "d", + "h", + "x", + "c" + ], + "output": [ + "BOS", + "c", + "x", + "h", + "d", + "u", + "x", + "k", + "k", + "w" + ] + }, + { + "input": [ + "BOS", + "v", + "u", + "b", + "x", + "l", + "f", + "b", + "u", + "a" + ], + "output": [ + "BOS", + "a", + "u", + "b", + "f", + "l", + "x", + "b", + "u", + "v" + ] + }, + { + "input": [ + "BOS", + "g", + "t", + "o", + "k", + "h", + "u", + "g", + "z", + "s" + ], + "output": [ + "BOS", + "s", + "z", + "g", + "u", + "h", + "k", + "o", + "t", + "g" + ] + }, + { + "input": [ + "BOS", + "o", + "s", + "l", + "w", + "t", + "y", + "c", + "e", + "s" + ], + "output": [ + "BOS", + "s", + "e", + "c", + "y", + "t", + "w", + "l", + "s", + "o" + ] + } + ], + "is_categorical": true + }, + "program": "length = make_length(); opp_idx = length - indices; opp_idx_minus_1 = opp_idx - 1; reverse_selector = Select(indices, opp_idx_minus_1, EQ); reverse = Aggregate(reverse_selector, tokens)", + "components": [ + { + "id": "L0H0_ATTN", + "hook": "blocks.0.attn.hook_result[0]", + "role": { + "tag": "AGGREGATOR", + "note": "Produces a sequence-length signal by counting tokens via the attention output width." + }, + "rasp_vars": [ + "length" + ], + "labels": [ + "length_5_selector_width_attn_output" + ] + }, + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Computes sequence length feature from the length-related signal produced by the attention head." + }, + "rasp_vars": [ + "length" + ], + "labels": [ + "length_5", + "length_5_selector_width_attn_output" + ] + }, + { + "id": "L1_MLP", + "hook": "blocks.1.mlp.hook_post", + "role": { + "tag": "COMBINER", + "note": "For each position, computes which position it should pull from to create the reversed order." + }, + "rasp_vars": [ + "opp_idx" + ], + "labels": [ + "opp_idx_4" + ] + }, + { + "id": "L2_MLP", + "hook": "blocks.2.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Adjusts the computed source position so it lines up with the correct reverse indexing." + }, + "rasp_vars": [ + "opp_idx_minus_1" + ], + "labels": [ + "opp_idx-1_3" + ] + }, + { + "id": "L3H0_ATTN", + "hook": "blocks.3.attn.hook_result[0]", + "role": { + "tag": "ROUTER", + "note": "Moves tokens so every output position receives the token from its mirrored position, producing the reversed sequence." + }, + "rasp_vars": [ + "reverse_selector", + "reverse" + ], + "labels": [ + "reverse_1" + ] + } + ] +} diff --git a/annotations/case_20.json b/annotations/case_20.json new file mode 100644 index 0000000000000000000000000000000000000000..2e0a0991969312ea2b6fe488ab22890619d7bfb9 --- /dev/null +++ b/annotations/case_20.json @@ -0,0 +1,158 @@ +{ + "task": { + "id": "case_20", + "name": "spam_message_detector", + "summary": "Detect spam messages based on appearance of spam keywords.", + "examples": [ + { + "input": [ + "BOS", + "poiVg", + "poiVg", + "now", + "b", + "V", + "now", + "now", + "TPSI", + "click" + ], + "output": [ + "BOS", + "not spam", + "not spam", + "spam", + "not spam", + "not spam", + "spam", + "spam", + "not spam", + "spam" + ] + }, + { + "input": [ + "BOS", + "spam", + "offer", + "click", + "spam", + "oCLrZaW", + "J", + "poiVg", + "poiVg", + "offer" + ], + "output": [ + "BOS", + "not spam", + "spam", + "spam", + "not spam", + "not spam", + "not spam", + "not spam", + "not spam", + "spam" + ] + }, + { + "input": [ + "BOS", + "no", + "V", + "poiVg", + "now", + "b", + "no", + "offer", + "TPSI", + "no" + ], + "output": [ + "BOS", + "not spam", + "not spam", + "not spam", + "spam", + "not spam", + "not spam", + "spam", + "not spam", + "not spam" + ] + }, + { + "input": [ + "BOS", + "spam", + "spam", + "TPSI", + "spam", + "no", + "V", + "oCLrZaW", + "TPSI", + "b" + ], + "output": [ + "BOS", + "not spam", + "not spam", + "not spam", + "not spam", + "not spam", + "not spam", + "not spam", + "not spam", + "not spam" + ] + }, + { + "input": [ + "BOS", + "b", + "LB", + "now", + "spam", + "click", + "LB", + "spam", + "b", + "J" + ], + "output": [ + "BOS", + "not spam", + "not spam", + "spam", + "not spam", + "spam", + "not spam", + "not spam", + "not spam", + "not spam" + ] + } + ], + "is_categorical": true + }, + "program": "spam_keywords = {\"free\", \"offer\", \"click\", \"now\"}\nkeyword_count = rasp.Map(lambda x: sum(x == keyword for keyword in spam_keywords), sop)\nis_spam = rasp.Map(lambda x: \"spam\" if x > 0 else \"not spam\", keyword_count)\nreturn is_spam", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Checks each token for membership in a spam-keyword set and emits a spam/not-spam label for that position." + }, + "rasp_vars": [ + "keyword_count", + "is_spam" + ], + "labels": [ + "map_1" + ] + } + ] +} diff --git a/annotations/case_21.json b/annotations/case_21.json new file mode 100644 index 0000000000000000000000000000000000000000..7bdec062c1e506579cbb7a1db3557af9fb3a7e13 --- /dev/null +++ b/annotations/case_21.json @@ -0,0 +1,214 @@ +{ + "task": { + "id": "case_21", + "name": "unique_token_extractor", + "summary": "Extract unique tokens from a string", + "examples": [ + { + "input": [ + "BOS", + "b", + "b", + "a", + "a", + "b", + "b", + "a", + "a", + "a" + ], + "output": [ + "BOS", + "b", + null, + "a", + null, + null, + null, + null, + null, + null + ] + }, + { + "input": [ + "BOS", + "c", + "c", + "a", + "c", + "a", + "c", + "c", + "a", + "a" + ], + "output": [ + "BOS", + "c", + null, + "a", + null, + null, + null, + null, + null, + null + ] + }, + { + "input": [ + "BOS", + "c", + "a", + "c", + "c", + "a", + "a", + "c", + "b", + "c" + ], + "output": [ + "BOS", + "c", + "a", + null, + null, + null, + null, + null, + "b", + null + ] + }, + { + "input": [ + "BOS", + "c", + "c", + "c", + "b", + "c", + "b", + "b", + "c", + "b" + ], + "output": [ + "BOS", + "c", + null, + null, + "b", + null, + null, + null, + null, + null + ] + }, + { + "input": [ + "BOS", + "c", + "c", + "c", + "a", + "c", + "b", + "a", + "b", + "b" + ], + "output": [ + "BOS", + "c", + null, + null, + "a", + null, + "b", + null, + null, + null + ] + } + ], + "is_categorical": true + }, + "program": "tokens_with_indices = rasp.SequenceMap(lambda x, i: (x, i), sop, rasp.indices)\noccurrences_selector = rasp.Select(tokens_with_indices, tokens_with_indices, lambda k, q: k[0] == q[0] and k[1] <= q[1])\noccurrences_per_row = rasp.SelectorWidth(occurrences_selector)\nfirst_occurrences_indices = rasp.SequenceMap(lambda count, i: i if count == 1 else -1, occurrences_per_row, rasp.indices)\ntokens_selector = rasp.Select(first_occurrences_indices, rasp.indices, rasp.Comparison.EQ).named(\"unique_tokens_selector\")\nreturn rasp.Aggregate(tokens_selector, sop, default=None).named(\"unique_tokens\")", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "COMBINER", + "note": "Creates a combined 'token + position' representation so later steps can tell which token occurred where." + }, + "rasp_vars": [ + "tokens_with_indices" + ], + "labels": [ + "sequence_map_6" + ] + }, + { + "id": "L1H0_ATTN", + "hook": "blocks.1.attn.hook_result[0]", + "role": { + "tag": "AGGREGATOR", + "note": "Aggregates matching positions (same token, earlier-or-equal index) into a per-position count of how many times each token has appeared up to and including the current position." + }, + "rasp_vars": [ + "occurrences_selector" + ], + "labels": [ + "selector_width_4_selector_width_attn_output" + ] + }, + { + "id": "L1_MLP", + "hook": "blocks.1.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Converts the per-position summary into the explicit running count of that token's occurrences so far. (how many times this token has appeared up to here)." + }, + "rasp_vars": [ + "occurrences_per_row" + ], + "labels": [ + "selector_width_4", + "selector_width_4_selector_width_attn_output" + ] + }, + { + "id": "L2_MLP", + "hook": "blocks.2.mlp.hook_post", + "role": { + "tag": "COMBINER", + "note": "Computes a per-position routing key that marks the first occurrence positions and marks all others as an invalid index." + }, + "rasp_vars": [ + "first_occurrences_indices" + ], + "labels": [ + "sequence_map_3" + ] + }, + { + "id": "L3H0_ATTN", + "hook": "blocks.3.attn.hook_result[0]", + "role": { + "tag": "AGGREGATOR", + "note": "Attends to the position (if any) whose 'first occurrences indices' equals the current index, and aggregates the token value from there, or None if no such position exists." + }, + "rasp_vars": [ + "unique_tokens" + ], + "labels": [ + "unique_tokens_1" + ] + } + ] +} diff --git a/annotations/case_24.json b/annotations/case_24.json new file mode 100644 index 0000000000000000000000000000000000000000..1921f8e523e3dc9df822613d21d0bb6f6f8ecc05 --- /dev/null +++ b/annotations/case_24.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_24", + "name": "first_occurrence", + "summary": "Copies each token in the sequence to the output unchanged.", + "examples": [ + { + "input": [ + "BOS", + "b", + "b", + "a", + "a", + "b", + "b", + "a", + "a", + "a" + ], + "output": [ + "BOS", + "b", + "b", + "a", + "a", + "b", + "b", + "a", + "a", + "a" + ] + }, + { + "input": [ + "BOS", + "c", + "c", + "a", + "c", + "a", + "c", + "c", + "a", + "a" + ], + "output": [ + "BOS", + "c", + "c", + "a", + "c", + "a", + "c", + "c", + "a", + "a" + ] + }, + { + "input": [ + "BOS", + "c", + "a", + "c", + "c", + "a", + "a", + "c", + "b", + "c" + ], + "output": [ + "BOS", + "c", + "a", + "c", + "c", + "a", + "a", + "c", + "b", + "c" + ] + }, + { + "input": [ + "BOS", + "c", + "c", + "c", + "b", + "c", + "b", + "b", + "c", + "b" + ], + "output": [ + "BOS", + "c", + "c", + "c", + "b", + "c", + "b", + "b", + "c", + "b" + ] + }, + { + "input": [ + "BOS", + "c", + "c", + "c", + "a", + "c", + "b", + "a", + "b", + "b" + ], + "output": [ + "BOS", + "c", + "c", + "c", + "a", + "c", + "b", + "a", + "b", + "b" + ] + } + ], + "is_categorical": true + }, + "program": "first_occurrence = rasp.Aggregate(rasp.Select(rasp.indices, rasp.indices, rasp.Comparison.EQ), sop, default=None).named(\"first_occurrence\"); return first_occurrence", + "components": [ + { + "id": "L0H0_ATTN", + "hook": "blocks.0.attn.hook_result[0]", + "role": { + "tag": "ROUTER", + "note": "Routes each position's token value to itself via an identity attention pattern. Each query position attends exclusively to its own key position, acting as a pass-through." + }, + "rasp_vars": [ + "first_occurrence" + ], + "labels": [ + "first_occurrence_1" + ] + } + ] +} diff --git a/annotations/case_25.json b/annotations/case_25.json new file mode 100644 index 0000000000000000000000000000000000000000..ec87c19523a4a7c51d2ae750a1e54b6793090ee6 --- /dev/null +++ b/annotations/case_25.json @@ -0,0 +1,203 @@ +{ + "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" + ] + } + ] +} diff --git a/annotations/case_26.json b/annotations/case_26.json new file mode 100644 index 0000000000000000000000000000000000000000..bef5f3354c9f2414d2f7dc2b02af34a87fec7207 --- /dev/null +++ b/annotations/case_26.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_26", + "name": "token_cascade", + "summary": "Creates a cascading effect by repeating each token in sequence incrementally.", + "examples": [ + { + "input": [ + "BOS", + "b", + "b", + "a", + "a", + "b", + "b", + "a", + "a", + "a" + ], + "output": [ + "BOS", + "b", + "bb", + "aaa", + "aaaa", + "bbbbb", + "bbbbbb", + "aaaaaaa", + "aaaaaaaa", + "aaaaaaaaa" + ] + }, + { + "input": [ + "BOS", + "c", + "c", + "a", + "c", + "a", + "c", + "c", + "a", + "a" + ], + "output": [ + "BOS", + "c", + "cc", + "aaa", + "cccc", + "aaaaa", + "cccccc", + "ccccccc", + "aaaaaaaa", + "aaaaaaaaa" + ] + }, + { + "input": [ + "BOS", + "c", + "a", + "c", + "c", + "a", + "a", + "c", + "b", + "c" + ], + "output": [ + "BOS", + "c", + "aa", + "ccc", + "cccc", + "aaaaa", + "aaaaaa", + "ccccccc", + "bbbbbbbb", + "ccccccccc" + ] + }, + { + "input": [ + "BOS", + "c", + "c", + "c", + "b", + "c", + "b", + "b", + "c", + "b" + ], + "output": [ + "BOS", + "c", + "cc", + "ccc", + "bbbb", + "ccccc", + "bbbbbb", + "bbbbbbb", + "cccccccc", + "bbbbbbbbb" + ] + }, + { + "input": [ + "BOS", + "c", + "c", + "c", + "a", + "c", + "b", + "a", + "b", + "b" + ], + "output": [ + "BOS", + "c", + "cc", + "ccc", + "aaaa", + "ccccc", + "bbbbbb", + "aaaaaaa", + "bbbbbbbb", + "bbbbbbbbb" + ] + } + ], + "is_categorical": true + }, + "program": "cascade_sop = rasp.SequenceMap(lambda x, i: x * (i + 1), sop, rasp.indices)\nreturn cascade_sop", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "COMBINER", + "note": "Combines each token with its position index to repeat the token an increasing number of times across the sequence." + }, + "rasp_vars": [ + "cascade_sop" + ], + "labels": [ + "sequence_map_1" + ] + } + ] +} diff --git a/annotations/case_29.json b/annotations/case_29.json new file mode 100644 index 0000000000000000000000000000000000000000..65badf51946bafd04c532d535496d4db42bcddf1 --- /dev/null +++ b/annotations/case_29.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_29", + "name": "token_abbreviation", + "summary": "Creates abbreviations for each token in the sequence.", + "examples": [ + { + "input": [ + "BOS", + "oCLrZaW", + "V", + "b", + "oCLrZaW", + "TPSI", + "poiVg", + "b", + "b", + "oCLrZaW" + ], + "output": [ + "BOS", + "oCL", + "V", + "b", + "oCL", + "TPS", + "poi", + "b", + "b", + "oCL" + ] + }, + { + "input": [ + "BOS", + "LB", + "TPSI", + "oCLrZaW", + "TPSI", + "TPSI", + "poiVg", + "b", + "V", + "poiVg" + ], + "output": [ + "BOS", + "LB", + "TPS", + "oCL", + "TPS", + "TPS", + "poi", + "b", + "V", + "poi" + ] + }, + { + "input": [ + "BOS", + "poiVg", + "TPSI", + "no", + "b", + "LB", + "poiVg", + "V", + "no", + "no" + ], + "output": [ + "BOS", + "poi", + "TPS", + "no", + "b", + "LB", + "poi", + "V", + "no", + "no" + ] + }, + { + "input": [ + "BOS", + "V", + "J", + "J", + "TPSI", + "TPSI", + "oCLrZaW", + "LB", + "poiVg", + "V" + ], + "output": [ + "BOS", + "V", + "J", + "J", + "TPS", + "TPS", + "oCL", + "LB", + "poi", + "V" + ] + }, + { + "input": [ + "BOS", + "LB", + "poiVg", + "V", + "b", + "J", + "V", + "LB", + "no", + "b" + ], + "output": [ + "BOS", + "LB", + "poi", + "V", + "b", + "J", + "V", + "LB", + "no", + "b" + ] + } + ], + "is_categorical": true + }, + "program": "abbreviation = rasp.Map(lambda x: x[:3] if len(x) > 3 else x, sop); return abbreviation", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Applies elementwise abbreviation rule, truncates to first 3 chars if len>3, else keeps token." + }, + "rasp_vars": [ + "abbreviation" + ], + "labels": [ + "map_1" + ] + } + ] +} diff --git a/annotations/case_3.json b/annotations/case_3.json new file mode 100644 index 0000000000000000000000000000000000000000..20826b59acd3f85c09a7c955d61baeda814c2ce5 --- /dev/null +++ b/annotations/case_3.json @@ -0,0 +1,122 @@ +{ + "task": { + "id": "case_3", + "name": "frac_prevs", + "summary": "Returns the fraction of 'x' in the input up to the i-th position for all i.", + "examples": [ + { + "input": [ + "BOS", + "c", + "x", + "a", + "c" + ], + "output": [ + "BOS", + 0.0, + 0.5, + 0.3333333333333333, + 0.25 + ] + }, + { + "input": [ + "BOS", + "c", + "b", + "c", + "c" + ], + "output": [ + "BOS", + 0.0, + 0.0, + 0.0, + 0.0 + ] + }, + { + "input": [ + "BOS", + "c", + "c", + "x", + "a" + ], + "output": [ + "BOS", + 0.0, + 0.0, + 0.3333333333333333, + 0.25 + ] + }, + { + "input": [ + "BOS", + "c", + "x", + "a", + "a" + ], + "output": [ + "BOS", + 0.0, + 0.5, + 0.3333333333333333, + 0.25 + ] + }, + { + "input": [ + "BOS", + "x", + "x", + "x", + "c" + ], + "output": [ + "BOS", + 1.0, + 1.0, + 1.0, + 0.75 + ] + } + ], + "is_categorical": false + }, + "program": "is_x = (rasp.tokens == \"x\").named(\"is_x\"); bools = rasp.numerical(is_x); prevs = rasp.Select(rasp.indices, rasp.indices, rasp.Comparison.LEQ); return rasp.numerical(rasp.Aggregate(prevs, bools, default=0)).named(\"frac_prevs\")", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "INDICATOR", + "note": "Computes per-position feature indicating whether the token at that position is 'x' or not." + }, + "rasp_vars": [ + "is_x" + ], + "labels": [ + "is_x_3" + ] + }, + { + "id": "L1H2_ATTN", + "hook": "blocks.1.attn.hook_result[2]", + "role": { + "tag": "AGGREGATOR", + "note": "Aggregates prefix fraction by attending over previous positions." + }, + "rasp_vars": [ + "prevs", + "frac_prevs" + ], + "labels": [ + "frac_prevs_1" + ] + } + ] +} diff --git a/annotations/case_30.json b/annotations/case_30.json new file mode 100644 index 0000000000000000000000000000000000000000..3b66231b79ce241b16f671521b0689b78bac144e --- /dev/null +++ b/annotations/case_30.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_30", + "name": "numeric_range_tagging", + "summary": "Tags numeric tokens in a sequence based on whether they fall within a given range.", + "examples": [ + { + "input": [ + "BOS", + "14", + "26", + "8", + "21", + "18", + "15", + "8", + "27", + "14" + ], + "output": [ + "BOS", + true, + false, + false, + false, + true, + true, + false, + false, + true + ] + }, + { + "input": [ + "BOS", + "5", + "25", + "29", + "18", + "18", + "3", + "27", + "11", + "15" + ], + "output": [ + "BOS", + false, + false, + false, + true, + true, + false, + false, + true, + true + ] + }, + { + "input": [ + "BOS", + "4", + "23", + "6", + "6", + "17", + "7", + "7", + "22", + "21" + ], + "output": [ + "BOS", + false, + false, + false, + false, + true, + false, + false, + false, + false + ] + }, + { + "input": [ + "BOS", + "1", + "7", + "27", + "0", + "19", + "5", + "28", + "8", + "19" + ], + "output": [ + "BOS", + false, + false, + false, + false, + true, + false, + false, + false, + true + ] + }, + { + "input": [ + "BOS", + "3", + "10", + "28", + "27", + "1", + "3", + "19", + "9", + "13" + ], + "output": [ + "BOS", + false, + true, + false, + false, + false, + false, + true, + false, + true + ] + } + ], + "is_categorical": true + }, + "program": "range_tagging = rasp.Map(lambda x: lower_bound <= int(x) <= upper_bound if x.isdigit() else False, sop)\nreturn range_tagging", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "INDICATOR", + "note": "Applies a per-token range test and outputs a boolean tag for each position." + }, + "rasp_vars": [ + "range_tagging" + ], + "labels": [ + "map_1" + ] + } + ] +} diff --git a/annotations/case_31.json b/annotations/case_31.json new file mode 100644 index 0000000000000000000000000000000000000000..81cbd53915b8fb4977c9bd2cf90b11d5f258544d --- /dev/null +++ b/annotations/case_31.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_31", + "name": "token_anagram_identifier", + "summary": "Identify if tokens in the sequence are anagrams of the word 'listen'.", + "examples": [ + { + "input": [ + "BOS", + "V", + "poiVg", + "LB", + "poiVg", + "b", + "LB", + "V", + "no", + "oCLrZaW" + ], + "output": [ + "BOS", + false, + false, + false, + false, + false, + false, + false, + false, + false + ] + }, + { + "input": [ + "BOS", + "poiVg", + "TPSI", + "b", + "TPSI", + "no", + "b", + "poiVg", + "no", + "LB" + ], + "output": [ + "BOS", + false, + false, + false, + false, + false, + false, + false, + false, + false + ] + }, + { + "input": [ + "BOS", + "no", + "V", + "oCLrZaW", + "b", + "no", + "TPSI", + "no", + "oCLrZaW", + "b" + ], + "output": [ + "BOS", + false, + false, + false, + false, + false, + false, + false, + false, + false + ] + }, + { + "input": [ + "BOS", + "V", + "oCLrZaW", + "oCLrZaW", + "TPSI", + "listen", + "b", + "LB", + "oCLrZaW", + "listen" + ], + "output": [ + "BOS", + false, + false, + false, + false, + true, + false, + false, + false, + true + ] + }, + { + "input": [ + "BOS", + "LB", + "b", + "J", + "listen", + "poiVg", + "J", + "TPSI", + "no", + "V" + ], + "output": [ + "BOS", + false, + false, + false, + true, + false, + false, + false, + false, + false + ] + } + ], + "is_categorical": true + }, + "program": "sorted_target = sorted(target)\nanagram_identifier = rasp.Map(lambda x: sorted(x) == sorted_target, sop)\nreturn anagram_identifier", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "INDICATOR", + "note": "Checks each token against the target anagram condition and outputs a boolean." + }, + "rasp_vars": [ + "anagram_identifier" + ], + "labels": [ + "map_1" + ] + } + ] +} diff --git a/annotations/case_33.json b/annotations/case_33.json new file mode 100644 index 0000000000000000000000000000000000000000..57926633abe2fa5a3c7822c190016e8c7378343d --- /dev/null +++ b/annotations/case_33.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_33", + "name": "token_length_parity", + "summary": "Checks if each token's length is odd or even.", + "examples": [ + { + "input": [ + "BOS", + "oCLrZaW", + "V", + "b", + "oCLrZaW", + "TPSI", + "poiVg", + "b", + "b", + "oCLrZaW" + ], + "output": [ + "BOS", + false, + false, + false, + false, + true, + false, + false, + false, + false + ] + }, + { + "input": [ + "BOS", + "LB", + "TPSI", + "oCLrZaW", + "TPSI", + "TPSI", + "poiVg", + "b", + "V", + "poiVg" + ], + "output": [ + "BOS", + true, + true, + false, + true, + true, + false, + false, + false, + false + ] + }, + { + "input": [ + "BOS", + "poiVg", + "TPSI", + "no", + "b", + "LB", + "poiVg", + "V", + "no", + "no" + ], + "output": [ + "BOS", + false, + true, + true, + false, + true, + false, + false, + true, + true + ] + }, + { + "input": [ + "BOS", + "V", + "J", + "J", + "TPSI", + "TPSI", + "oCLrZaW", + "LB", + "poiVg", + "V" + ], + "output": [ + "BOS", + false, + false, + false, + true, + true, + false, + true, + false, + false + ] + }, + { + "input": [ + "BOS", + "LB", + "poiVg", + "V", + "b", + "J", + "V", + "LB", + "no", + "b" + ], + "output": [ + "BOS", + true, + false, + false, + false, + false, + false, + true, + true, + false + ] + } + ], + "is_categorical": true + }, + "program": "length_parity_checker = rasp.Map(lambda x: len(x) % 2 == 0, sop)\nreturn length_parity_checker", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Computes a boolean per token indicating whether its length is even." + }, + "rasp_vars": [ + "length_parity_checker" + ], + "labels": [ + "map_1" + ] + } + ] +} diff --git a/annotations/case_34.json b/annotations/case_34.json new file mode 100644 index 0000000000000000000000000000000000000000..fce3ac7d5252f1b5ebb4afde4cb9b2f81d77a962 --- /dev/null +++ b/annotations/case_34.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_34", + "name": "vowel_consonant_ratio", + "summary": "Calculate the ratio of vowels to consonants in each word.", + "examples": [ + { + "input": [ + "BOS", + "oCLrZaW", + "V", + "b", + "oCLrZaW", + "TPSI", + "poiVg", + "b", + "b", + "oCLrZaW" + ], + "output": [ + "BOS", + 0.4, + 0.0, + 0.0, + 0.4, + 0.3333333333333333, + 0.6666666666666666, + 0.0, + 0.0, + 0.4 + ] + }, + { + "input": [ + "BOS", + "LB", + "TPSI", + "oCLrZaW", + "TPSI", + "TPSI", + "poiVg", + "b", + "V", + "poiVg" + ], + "output": [ + "BOS", + 0.0, + 0.3333333333333333, + 0.4, + 0.3333333333333333, + 0.3333333333333333, + 0.6666666666666666, + 0.0, + 0.0, + 0.6666666666666666 + ] + }, + { + "input": [ + "BOS", + "poiVg", + "TPSI", + "no", + "b", + "LB", + "poiVg", + "V", + "no", + "no" + ], + "output": [ + "BOS", + 0.6666666666666666, + 0.3333333333333333, + 1.0, + 0.0, + 0.0, + 0.6666666666666666, + 0.0, + 1.0, + 1.0 + ] + }, + { + "input": [ + "BOS", + "V", + "J", + "J", + "TPSI", + "TPSI", + "oCLrZaW", + "LB", + "poiVg", + "V" + ], + "output": [ + "BOS", + 0.0, + 0.0, + 0.0, + 0.3333333333333333, + 0.3333333333333333, + 0.4, + 0.0, + 0.6666666666666666, + 0.0 + ] + }, + { + "input": [ + "BOS", + "LB", + "poiVg", + "V", + "b", + "J", + "V", + "LB", + "no", + "b" + ], + "output": [ + "BOS", + 0.0, + 0.6666666666666666, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0 + ] + } + ], + "is_categorical": true + }, + "program": "ratio_calculator = rasp.Map(calc_ratio, sop)\nreturn ratio_calculator", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Computes, for each token, the vowel-to-consonant ratio (with an infinity output when there are no consonants)." + }, + "rasp_vars": [ + "ratio_calculator" + ], + "labels": [ + "map_1" + ] + } + ] +} diff --git a/annotations/case_35.json b/annotations/case_35.json new file mode 100644 index 0000000000000000000000000000000000000000..9259cb25c896be2d6f76e436172a4558eaad1f66 --- /dev/null +++ b/annotations/case_35.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_35", + "name": "token_capitalization_alternator", + "summary": "Alternates capitalization of each character in words.", + "examples": [ + { + "input": [ + "BOS", + "oCLrZaW", + "V", + "b", + "oCLrZaW", + "TPSI", + "poiVg", + "b", + "b", + "oCLrZaW" + ], + "output": [ + "BOS", + "OcLrZaW", + "V", + "B", + "OcLrZaW", + "TpSi", + "PoIvG", + "B", + "B", + "OcLrZaW" + ] + }, + { + "input": [ + "BOS", + "LB", + "TPSI", + "oCLrZaW", + "TPSI", + "TPSI", + "poiVg", + "b", + "V", + "poiVg" + ], + "output": [ + "BOS", + "Lb", + "TpSi", + "OcLrZaW", + "TpSi", + "TpSi", + "PoIvG", + "B", + "V", + "PoIvG" + ] + }, + { + "input": [ + "BOS", + "poiVg", + "TPSI", + "no", + "b", + "LB", + "poiVg", + "V", + "no", + "no" + ], + "output": [ + "BOS", + "PoIvG", + "TpSi", + "No", + "B", + "Lb", + "PoIvG", + "V", + "No", + "No" + ] + }, + { + "input": [ + "BOS", + "V", + "J", + "J", + "TPSI", + "TPSI", + "oCLrZaW", + "LB", + "poiVg", + "V" + ], + "output": [ + "BOS", + "V", + "J", + "J", + "TpSi", + "TpSi", + "OcLrZaW", + "Lb", + "PoIvG", + "V" + ] + }, + { + "input": [ + "BOS", + "LB", + "poiVg", + "V", + "b", + "J", + "V", + "LB", + "no", + "b" + ], + "output": [ + "BOS", + "Lb", + "PoIvG", + "V", + "B", + "J", + "V", + "Lb", + "No", + "B" + ] + } + ], + "is_categorical": true + }, + "program": "def alternate_capitalization(word):\n return ''.join(c.upper() if i % 2 == 0 else c.lower() for i, c in enumerate(word))\n\nalternator = rasp.Map(alternate_capitalization, sop)\nreturn alternator", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Transforms each token independently by applying a consistent per-character formatting rule." + }, + "rasp_vars": [ + "alternator" + ], + "labels": [ + "map_1" + ] + } + ] +} diff --git a/annotations/case_36.json b/annotations/case_36.json new file mode 100644 index 0000000000000000000000000000000000000000..f4f7947f6e92d2f5db54d32017caeba90baeffce --- /dev/null +++ b/annotations/case_36.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_36", + "name": "emoji_sentiment_classifier", + "summary": "Classifies each token as 'positive', 'negative', or 'neutral' based on emojis.", + "examples": [ + { + "input": [ + "BOS", + "😊", + "😊", + "📘", + "📘", + "😊", + "😊", + "📘", + "📘", + "📘" + ], + "output": [ + "BOS", + "positive", + "positive", + "neutral", + "neutral", + "positive", + "positive", + "neutral", + "neutral", + "neutral" + ] + }, + { + "input": [ + "BOS", + "😢", + "😢", + "📘", + "😢", + "📘", + "😢", + "😢", + "📘", + "📘" + ], + "output": [ + "BOS", + "negative", + "negative", + "neutral", + "negative", + "neutral", + "negative", + "negative", + "neutral", + "neutral" + ] + }, + { + "input": [ + "BOS", + "😢", + "📘", + "😢", + "😢", + "📘", + "📘", + "😢", + "😊", + "😢" + ], + "output": [ + "BOS", + "negative", + "neutral", + "negative", + "negative", + "neutral", + "neutral", + "negative", + "positive", + "negative" + ] + }, + { + "input": [ + "BOS", + "😢", + "😢", + "😢", + "😊", + "😢", + "😊", + "😊", + "😢", + "😊" + ], + "output": [ + "BOS", + "negative", + "negative", + "negative", + "positive", + "negative", + "positive", + "positive", + "negative", + "positive" + ] + }, + { + "input": [ + "BOS", + "😢", + "😢", + "😢", + "📘", + "😢", + "😊", + "📘", + "😊", + "😊" + ], + "output": [ + "BOS", + "negative", + "negative", + "negative", + "neutral", + "negative", + "positive", + "neutral", + "positive", + "positive" + ] + } + ], + "is_categorical": true + }, + "program": "emoji_sentiments = {\"😊\": \"positive\", \"😢\": \"negative\", \"📘\": \"neutral\"}\nclassify_sentiment = rasp.Map(lambda x: emoji_sentiments.get(x, \"neutral\"), sop)\nreturn classify_sentiment", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Assigns a category to each token using a fixed lookup rule." + }, + "rasp_vars": [ + "classify_sentiment" + ], + "labels": [ + "map_1" + ] + } + ] +} diff --git a/annotations/case_37.json b/annotations/case_37.json new file mode 100644 index 0000000000000000000000000000000000000000..69462cfef9e48cc52997bc07bfb6fbd740bcac19 --- /dev/null +++ b/annotations/case_37.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_37", + "name": "token_reversal_with_exclusion", + "summary": "Reverses each word in the sequence except for specified exclusions.", + "examples": [ + { + "input": [ + "BOS", + "oCLrZaW", + "V", + "b", + "oCLrZaW", + "TPSI", + "poiVg", + "b", + "b", + "oCLrZaW" + ], + "output": [ + "BOS", + "WaZrLCo", + "V", + "b", + "WaZrLCo", + "ISPT", + "gViop", + "b", + "b", + "WaZrLCo" + ] + }, + { + "input": [ + "BOS", + "LB", + "TPSI", + "oCLrZaW", + "TPSI", + "TPSI", + "poiVg", + "b", + "V", + "poiVg" + ], + "output": [ + "BOS", + "BL", + "ISPT", + "WaZrLCo", + "ISPT", + "ISPT", + "gViop", + "b", + "V", + "gViop" + ] + }, + { + "input": [ + "BOS", + "poiVg", + "TPSI", + "no", + "b", + "LB", + "poiVg", + "V", + "no", + "no" + ], + "output": [ + "BOS", + "gViop", + "ISPT", + "on", + "b", + "BL", + "gViop", + "V", + "on", + "on" + ] + }, + { + "input": [ + "BOS", + "V", + "J", + "J", + "TPSI", + "TPSI", + "oCLrZaW", + "LB", + "poiVg", + "V" + ], + "output": [ + "BOS", + "V", + "J", + "J", + "ISPT", + "ISPT", + "WaZrLCo", + "BL", + "gViop", + "V" + ] + }, + { + "input": [ + "BOS", + "LB", + "poiVg", + "V", + "b", + "J", + "V", + "LB", + "no", + "b" + ], + "output": [ + "BOS", + "BL", + "gViop", + "V", + "b", + "J", + "V", + "BL", + "on", + "b" + ] + } + ], + "is_categorical": true + }, + "program": "reversal = rasp.Map(lambda x: x[::-1] if x != exclude else x, sop)\nreturn reversal", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Reverses each token unless it matches the excluded token, in which case it is passed through unchanged." + }, + "rasp_vars": [ + "reversal" + ], + "labels": [ + "map_1" + ] + } + ] +} diff --git a/annotations/case_39.json b/annotations/case_39.json new file mode 100644 index 0000000000000000000000000000000000000000..7831705e8f95412225bc70180e4c77410dd1658c --- /dev/null +++ b/annotations/case_39.json @@ -0,0 +1,671 @@ +{ + "task": { + "id": "case_39", + "name": "frac_prevs_long", + "summary": "Returns the fraction of 'x' in the input up to the i-th position for all i (longer sequence length).", + "examples": [ + { + "input": [ + "BOS", + "t", + "o", + "g", + "l", + "h", + "o", + "c", + "n", + "q", + "d", + "r", + "h", + "d", + "b", + "f", + "v", + "j", + "d", + "v", + "r", + "z", + "l", + "b", + "j", + "d", + "n", + "p", + "o", + "h", + "n", + "w", + "y", + "h", + "u", + "p", + "m", + "r", + "o", + "u", + "x", + "z", + "y", + "m", + "i", + "o", + "m", + "a", + "y", + "g", + "i", + "x", + "a", + "l", + "h", + "x", + "k", + "s", + "q", + "h" + ], + "output": [ + "BOS", + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.025, + 0.024390243902439025, + 0.023809523809523808, + 0.023255813953488372, + 0.022727272727272728, + 0.022222222222222223, + 0.021739130434782608, + 0.02127659574468085, + 0.020833333333333332, + 0.02040816326530612, + 0.02, + 0.0392156862745098, + 0.038461538461538464, + 0.03773584905660377, + 0.037037037037037035, + 0.05454545454545454, + 0.05357142857142857, + 0.05263157894736842, + 0.05172413793103448, + 0.05084745762711865 + ] + }, + { + "input": [ + "BOS", + "j", + "m", + "y", + "u", + "f", + "l", + "l", + "t", + "k", + "z", + "w", + "y", + "g", + "a", + "a", + "y", + "y", + "t", + "m", + "i", + "c", + "g", + "f", + "h", + "i", + "e", + "a", + "s", + "j", + "l", + "x", + "o", + "v", + "x", + "i", + "t", + "q", + "q", + "z", + "t", + "l", + "g", + "b", + "c", + "q", + "e", + "q", + "x", + "q", + "q", + "b", + "b", + "v", + "w", + "e", + "a", + "a", + "s", + "b" + ], + "output": [ + "BOS", + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.03225806451612903, + 0.03125, + 0.030303030303030304, + 0.058823529411764705, + 0.05714285714285714, + 0.05555555555555555, + 0.05405405405405406, + 0.05263157894736842, + 0.05128205128205128, + 0.05, + 0.04878048780487805, + 0.047619047619047616, + 0.046511627906976744, + 0.045454545454545456, + 0.044444444444444446, + 0.043478260869565216, + 0.0425531914893617, + 0.0625, + 0.061224489795918366, + 0.06, + 0.058823529411764705, + 0.057692307692307696, + 0.05660377358490566, + 0.05555555555555555, + 0.05454545454545454, + 0.05357142857142857, + 0.05263157894736842, + 0.05172413793103448, + 0.05084745762711865 + ] + }, + { + "input": [ + "BOS", + "c", + "c", + "a", + "e", + "j", + "g", + "z", + "i", + "g", + "i", + "h", + "l", + "b", + "a", + "p", + "w", + "w", + "x", + "e", + "c", + "l", + "h", + "v", + "c", + "a", + "c", + "e", + "o", + "n", + "c", + "a", + "e", + "z", + "w", + "n", + "g", + "i", + "o", + "o", + "z", + "j", + "m", + "s", + "g", + "q", + "t", + "d", + "e", + "w", + "g", + "m", + "o", + "k", + "d", + "m", + "g", + "s", + "v", + "b" + ], + "output": [ + "BOS", + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.05555555555555555, + 0.05263157894736842, + 0.05, + 0.047619047619047616, + 0.045454545454545456, + 0.043478260869565216, + 0.041666666666666664, + 0.04, + 0.038461538461538464, + 0.037037037037037035, + 0.03571428571428571, + 0.034482758620689655, + 0.03333333333333333, + 0.03225806451612903, + 0.03125, + 0.030303030303030304, + 0.029411764705882353, + 0.02857142857142857, + 0.027777777777777776, + 0.02702702702702703, + 0.02631578947368421, + 0.02564102564102564, + 0.025, + 0.024390243902439025, + 0.023809523809523808, + 0.023255813953488372, + 0.022727272727272728, + 0.022222222222222223, + 0.021739130434782608, + 0.02127659574468085, + 0.020833333333333332, + 0.02040816326530612, + 0.02, + 0.0196078431372549, + 0.019230769230769232, + 0.018867924528301886, + 0.018518518518518517, + 0.01818181818181818, + 0.017857142857142856, + 0.017543859649122806, + 0.017241379310344827, + 0.01694915254237288 + ] + }, + { + "input": [ + "BOS", + "g", + "t", + "o", + "k", + "h", + "u", + "g", + "z", + "s", + "w", + "k", + "k", + "x", + "u", + "d", + "h", + "x", + "c", + "v", + "u", + "b", + "x", + "l", + "f", + "b", + "u", + "a", + "l", + "z", + "v", + "l", + "y", + "q", + "j", + "p", + "o", + "o", + "s", + "l", + "w", + "t", + "y", + "c", + "e", + "s", + "g", + "u", + "i", + "g", + "r", + "d", + "y", + "n", + "r", + "z", + "i", + "z", + "u", + "b" + ], + "output": [ + "BOS", + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.07692307692307693, + 0.07142857142857142, + 0.06666666666666667, + 0.0625, + 0.11764705882352941, + 0.1111111111111111, + 0.10526315789473684, + 0.1, + 0.09523809523809523, + 0.13636363636363635, + 0.13043478260869565, + 0.125, + 0.12, + 0.11538461538461539, + 0.1111111111111111, + 0.10714285714285714, + 0.10344827586206896, + 0.1, + 0.0967741935483871, + 0.09375, + 0.09090909090909091, + 0.08823529411764706, + 0.08571428571428572, + 0.08333333333333333, + 0.08108108108108109, + 0.07894736842105263, + 0.07692307692307693, + 0.075, + 0.07317073170731707, + 0.07142857142857142, + 0.06976744186046512, + 0.06818181818181818, + 0.06666666666666667, + 0.06521739130434782, + 0.06382978723404255, + 0.0625, + 0.061224489795918366, + 0.06, + 0.058823529411764705, + 0.057692307692307696, + 0.05660377358490566, + 0.05555555555555555, + 0.05454545454545454, + 0.05357142857142857, + 0.05263157894736842, + 0.05172413793103448, + 0.05084745762711865 + ] + }, + { + "input": [ + "BOS", + "u", + "l", + "z", + "f", + "w", + "d", + "w", + "k", + "x", + "q", + "f", + "x", + "e", + "t", + "b", + "f", + "v", + "k", + "p", + "p", + "a", + "i", + "f", + "p", + "c", + "t", + "d", + "s", + "z", + "c", + "s", + "t", + "g", + "t", + "i", + "a", + "h", + "g", + "r", + "h", + "a", + "k", + "y", + "y", + "r", + "w", + "j", + "c", + "g", + "p", + "z", + "p", + "y", + "t", + "q", + "b", + "a", + "p", + "l" + ], + "output": [ + "BOS", + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.1111111111111111, + 0.1, + 0.09090909090909091, + 0.16666666666666666, + 0.15384615384615385, + 0.14285714285714285, + 0.13333333333333333, + 0.125, + 0.11764705882352941, + 0.1111111111111111, + 0.10526315789473684, + 0.1, + 0.09523809523809523, + 0.09090909090909091, + 0.08695652173913043, + 0.08333333333333333, + 0.08, + 0.07692307692307693, + 0.07407407407407407, + 0.07142857142857142, + 0.06896551724137931, + 0.06666666666666667, + 0.06451612903225806, + 0.0625, + 0.06060606060606061, + 0.058823529411764705, + 0.05714285714285714, + 0.05555555555555555, + 0.05405405405405406, + 0.05263157894736842, + 0.05128205128205128, + 0.05, + 0.04878048780487805, + 0.047619047619047616, + 0.046511627906976744, + 0.045454545454545456, + 0.044444444444444446, + 0.043478260869565216, + 0.0425531914893617, + 0.041666666666666664, + 0.04081632653061224, + 0.04, + 0.0392156862745098, + 0.038461538461538464, + 0.03773584905660377, + 0.037037037037037035, + 0.03636363636363636, + 0.03571428571428571, + 0.03508771929824561, + 0.034482758620689655, + 0.03389830508474576 + ] + } + ], + "is_categorical": false + }, + "program": "is_x = (rasp.tokens == \"x\").named(\"is_x\")\nbools = rasp.numerical(is_x); prevs = rasp.Select(rasp.indices, rasp.indices, rasp.Comparison.LEQ); return rasp.numerical(rasp.Aggregate(prevs, bools, default=0)).named(\"frac_prevs\")", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "INDICATOR", + "note": "Computes a per-position boolean feature indicating whether the current token is 'x'." + }, + "rasp_vars": [ + "is_x" + ], + "labels": [ + "is_x_3" + ] + }, + { + "id": "L1H0_ATTN", + "hook": "blocks.1.attn.hook_result[0]", + "role": { + "tag": "AGGREGATOR", + "note": "Aggregates the prefix of the sequence to produce the running fraction of 'x' up to each position." + }, + "rasp_vars": [ + "frac_prevs" + ], + "labels": [ + "frac_prevs_1" + ] + } + ] +} diff --git a/annotations/case_4.json b/annotations/case_4.json new file mode 100644 index 0000000000000000000000000000000000000000..f1576660da367c63e4c77f764014e9080c309911 --- /dev/null +++ b/annotations/case_4.json @@ -0,0 +1,188 @@ +{ + "task": { + "id": "case_4", + "name": "pair_balance", + "summary": "Return fraction of previous open tokens minus the fraction of close tokens.", + "examples": [ + { + "input": [ + "BOS", + "(", + "b", + ")", + "c", + "b", + "(", + "(", + "a", + "a" + ], + "output": [ + "BOS", + 1.0, + 0.5, + 0.0, + 0.0, + 0.0, + 0.16666666666666666, + 0.2857142857142857, + 0.25, + 0.2222222222222222 + ] + }, + { + "input": [ + "BOS", + ")", + "b", + "b", + "a", + "b", + "b", + "(", + "a", + "c" + ], + "output": [ + "BOS", + -1.0, + -0.5, + -0.3333333333333333, + -0.25, + -0.2, + -0.16666666666666666, + 0.0, + 0.0, + 0.0 + ] + }, + { + "input": [ + "BOS", + "a", + "c", + "(", + ")", + "b", + "(", + "b", + ")", + ")" + ], + "output": [ + "BOS", + 0.0, + 0.0, + 0.3333333333333333, + 0.0, + 0.0, + 0.16666666666666666, + 0.14285714285714285, + 0.0, + -0.1111111111111111 + ] + }, + { + "input": [ + "BOS", + "c", + "b", + "a", + "c", + ")", + "b", + ")", + "b", + "c" + ], + "output": [ + "BOS", + 0.0, + 0.0, + 0.0, + 0.0, + -0.2, + -0.16666666666666666, + -0.2857142857142857, + -0.25, + -0.2222222222222222 + ] + }, + { + "input": [ + "BOS", + "b", + "c", + "a", + "c", + "c", + ")", + "a", + "a", + "a" + ], + "output": [ + "BOS", + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + -0.16666666666666666, + -0.14285714285714285, + -0.125, + -0.1111111111111111 + ] + } + ], + "is_categorical": false + }, + "program": "bools_open = rasp.numerical(sop == open_token).named(\"bools_open\"); opens = rasp.numerical(make_frac_prevs(bools_open)).named(\"opens\"); bools_close = rasp.numerical(sop == close_token).named(\"bools_close\"); closes = rasp.numerical(make_frac_prevs(bools_close)).named(\"closes\"); pair_balance = rasp.numerical(rasp.LinearSequenceMap(opens, closes, 1, -1)); return pair_balance.named(\"pair_balance\")", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "INDICATOR", + "note": "Computes per-token indicator features for open and close tokens." + }, + "rasp_vars": [ + "bools_open", + "bools_close" + ] + }, + { + "id": "L1H0_ATTN", + "hook": "blocks.1.attn.hook_result[0]", + "role": { + "tag": "AGGREGATOR", + "note": "Computes prefix aggregate for opens (fraction/count up to i) by attending over previous positions and reading the open-indicator via values." + }, + "rasp_vars": [ + "opens" + ] + }, + { + "id": "L1H1_ATTN", + "hook": "blocks.1.attn.hook_result[1]", + "role": { + "tag": "AGGREGATOR", + "note": "Computes prefix aggregate for closes (fraction/count up to i) by attending over previous positions and reading the close-indicator via values." + }, + "rasp_vars": [ + "closes" + ] + }, + { + "id": "L1_MLP", + "hook": "blocks.1.mlp.hook_post", + "role": { + "tag": "COMBINER", + "note": "Combines the open and close aggregates to compute the final balanced pair output." + }, + "rasp_vars": [ + "pair_balance" + ] + } + ] +} diff --git a/annotations/case_40.json b/annotations/case_40.json new file mode 100644 index 0000000000000000000000000000000000000000..4c0efc3c3470ac3291ec33267079831c13541109 --- /dev/null +++ b/annotations/case_40.json @@ -0,0 +1,171 @@ +{ + "task": { + "id": "case_40", + "name": "sum_last_two_digits", + "summary": "Sum the last and previous to last digits of a number", + "examples": [ + { + "input": [ + "BOS", + 6, + 19, + 28, + 14, + 10, + 7, + 28, + 20, + 6 + ], + "output": [ + "BOS", + 6, + 10, + 10, + 5, + 1, + 7, + 10, + 2, + 6 + ] + }, + { + "input": [ + "BOS", + 25, + 18, + 22, + 10, + 10, + 23, + 20, + 3, + 7 + ], + "output": [ + "BOS", + 7, + 9, + 4, + 1, + 1, + 5, + 2, + 3, + 7 + ] + }, + { + "input": [ + "BOS", + 16, + 26, + 26, + 9, + 27, + 27, + 15, + 14, + 14 + ], + "output": [ + "BOS", + 7, + 8, + 8, + 9, + 9, + 9, + 6, + 5, + 5 + ] + }, + { + "input": [ + "BOS", + 27, + 20, + 0, + 11, + 25, + 21, + 28, + 11, + 24 + ], + "output": [ + "BOS", + 9, + 2, + 0, + 2, + 7, + 3, + 10, + 2, + 6 + ] + }, + { + "input": [ + "BOS", + 23, + 2, + 21, + 20, + 1, + 23, + 11, + 5, + 1 + ], + "output": [ + "BOS", + 5, + 2, + 3, + 2, + 1, + 5, + 2, + 5, + 1 + ] + } + ], + "is_categorical": true + }, + "program": "tens_place = rasp.Map(lambda x: x // 10, rasp.tokens).named(\"tens_place\")\nones_place = rasp.Map(lambda x: x % 10, rasp.tokens).named(\"ones_place\")\nsum_digits = rasp.SequenceMap(lambda x, y: x + y, tens_place, ones_place).named(\"sum_digits\")\nreturn sum_digits", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Derives the tens-place digit and also the ones-place digit from each input number." + }, + "rasp_vars": [ + "tens_place, ones_place" + ], + "labels": [ + "tens_place_2, ones_place_3" + ] + }, + { + "id": "L1_MLP", + "hook": "blocks.1.mlp.hook_post", + "role": { + "tag": "COMBINER", + "note": "Adds the tens-place and ones-place digits to produce the final per-token output." + }, + "rasp_vars": [ + "sum_digits" + ], + "labels": [ + "sum_digits_1" + ] + } + ] +} diff --git a/annotations/case_41.json b/annotations/case_41.json new file mode 100644 index 0000000000000000000000000000000000000000..20d35bb7fb43c78fd1d78d4a5dfc7c7f5270a8bd --- /dev/null +++ b/annotations/case_41.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_41", + "name": "make_absolute", + "summary": "Make each element of the input sequence absolute.", + "examples": [ + { + "input": [ + "BOS", + 7, + -2, + -9, + 9, + 4, + -4, + 1, + -3, + 4 + ], + "output": [ + "BOS", + 7, + 2, + 9, + 9, + 4, + 4, + 1, + 3, + 4 + ] + }, + { + "input": [ + "BOS", + -8, + -6, + 8, + -4, + -2, + -4, + 7, + -7, + 3 + ], + "output": [ + "BOS", + 8, + 6, + 8, + 4, + 2, + 4, + 7, + 7, + 3 + ] + }, + { + "input": [ + "BOS", + -4, + 9, + 4, + 0, + -3, + -4, + 8, + 0, + 0 + ], + "output": [ + "BOS", + 4, + 9, + 4, + 0, + 3, + 4, + 8, + 0, + 0 + ] + }, + { + "input": [ + "BOS", + -7, + -3, + -8, + -9, + 1, + -5, + -9, + -10, + 1 + ], + "output": [ + "BOS", + 7, + 3, + 8, + 9, + 1, + 5, + 9, + 10, + 1 + ] + }, + { + "input": [ + "BOS", + 1, + 6, + -1, + 5, + 4, + 4, + 8, + 1, + 9 + ], + "output": [ + "BOS", + 1, + 6, + 1, + 5, + 4, + 4, + 8, + 1, + 9 + ] + } + ], + "is_categorical": true + }, + "program": "return rasp.Map(lambda x: x if x >= 0 else -x, rasp.tokens).named(\"make_absolute\")", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Applies an element-wise absolute-value transform to each input number." + }, + "rasp_vars": [ + "make_absolute" + ], + "labels": [ + "make_absolute_1" + ] + } + ] +} diff --git a/annotations/case_43.json b/annotations/case_43.json new file mode 100644 index 0000000000000000000000000000000000000000..3089ee9780de19b4ebbf5ac9ab8e2d175e90241c --- /dev/null +++ b/annotations/case_43.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_43", + "name": "nth_fibonacci", + "summary": "Returns the corresponding Fibonacci number for each element in the input sequence.", + "examples": [ + { + "input": [ + "BOS", + 17, + 8, + 1, + 19, + 14, + 6, + 11, + 7, + 14 + ], + "output": [ + "BOS", + 1597, + 21, + 1, + 4181, + 377, + 8, + 89, + 13, + 377 + ] + }, + { + "input": [ + "BOS", + 2, + 4, + 18, + 6, + 8, + 6, + 17, + 3, + 13 + ], + "output": [ + "BOS", + 1, + 3, + 2584, + 8, + 21, + 8, + 1597, + 2, + 233 + ] + }, + { + "input": [ + "BOS", + 6, + 19, + 14, + 10, + 7, + 6, + 18, + 10, + 10 + ], + "output": [ + "BOS", + 8, + 4181, + 377, + 55, + 13, + 8, + 2584, + 55, + 55 + ] + }, + { + "input": [ + "BOS", + 3, + 7, + 2, + 1, + 11, + 5, + 1, + 0, + 11 + ], + "output": [ + "BOS", + 2, + 13, + 1, + 1, + 89, + 5, + 1, + 0, + 89 + ] + }, + { + "input": [ + "BOS", + 11, + 16, + 9, + 15, + 14, + 14, + 18, + 11, + 19 + ], + "output": [ + "BOS", + 89, + 987, + 34, + 610, + 377, + 377, + 2584, + 89, + 4181 + ] + } + ], + "is_categorical": true + }, + "program": "fib_sequence = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765]\nnth_fib = rasp.Map(lambda x: fib_sequence[x] if x < len(fib_sequence) else 0, rasp.tokens).named(\"nth_fib\")\nreturn nth_fib", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Maps each input index to its corresponding Fibonacci value using a fixed lookup table." + }, + "rasp_vars": [ + "nth_fib" + ], + "labels": [ + "nth_fib_1" + ] + } + ] +} diff --git a/annotations/case_44.json b/annotations/case_44.json new file mode 100644 index 0000000000000000000000000000000000000000..72cc29563c9b71c421c313eeae16757e4a9ab855 --- /dev/null +++ b/annotations/case_44.json @@ -0,0 +1,172 @@ +{ + "task": { + "id": "case_44", + "name": "count_greater_than", + "summary": "Replaces each element with the number of elements greater than it in the sequence", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 6, + 3, + 6, + 1, + 3, + 0, + 1, + 8, + 5 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 4, + 6, + 1, + 2, + 6, + 4, + 8, + 0, + 2 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 0, + 0, + 2, + 6, + 7, + 2, + 2, + 8, + 5 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 3, + 8, + 0, + 0, + 2, + 7, + 5, + 6, + 3 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 3, + 7, + 0, + 2, + 6, + 3, + 1, + 8, + 3 + ] + } + ], + "is_categorical": true + }, + "program": "greater_than_selector = rasp.Select(rasp.tokens, rasp.tokens, rasp.Comparison.GT).named(\"greater_than_selector\")\ncount_greater_than = rasp.SelectorWidth(greater_than_selector).named(\"count_greater_than\")\nreturn count_greater_than", + "components": [ + { + "id": "L0H0_ATTN", + "hook": "blocks.0.attn.hook_result[0]", + "role": { + "tag": "AGGREGATOR", + "note": "Attends to all positions whose token value is greater than the current position's token and produces a count of those matches" + }, + "rasp_vars": [ + "greater_than_selector" + ], + "labels": [ + "count_greater_than_1_selector_width_attn_output" + ] + }, + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Converts the aggregated attention signal into per-position counts of how many elements are greater." + }, + "rasp_vars": [ + "count_greater_than" + ], + "labels": [ + "count_greater_than_1", + "count_greater_than_1_selector_width_attn_output" + ] + } + ] +} diff --git a/annotations/case_45.json b/annotations/case_45.json new file mode 100644 index 0000000000000000000000000000000000000000..bd7ff3be44026baf27598804d4825f99ac3f6fe8 --- /dev/null +++ b/annotations/case_45.json @@ -0,0 +1,200 @@ +{ + "task": { + "id": "case_45", + "name": "double_first_half", + "summary": "Doubles the first half of the sequence", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 4, + 8, + 4, + 12, + 8, + 8, + 6, + 1, + 3 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 8, + 2, + 14, + 10, + 2, + 4, + 0, + 9, + 5 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 20, + 20, + 14, + 8, + 6, + 7, + 7, + 2, + 5 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 16, + 0, + 20, + 20, + 18, + 2, + 6, + 3, + 8 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 12, + 6, + 20, + 14, + 8, + 6, + 9, + 2, + 6 + ] + } + ], + "is_categorical": true + }, + "program": "length = rasp.SelectorWidth(rasp.Select(rasp.tokens, rasp.tokens, rasp.Comparison.TRUE)).named(\"length\")\nfirst_half_selector = rasp.SequenceMap(lambda idx, length: 1 if idx < length / 2 else 0, rasp.indices, length).named(\"first_half_selector\")\ndouble_first_half = rasp.SequenceMap(lambda x, sel: x * (1 + sel), rasp.tokens, first_half_selector).named(\"double_first_half\")\nreturn double_first_half", + "components": [ + { + "id": "L0H0_ATTN", + "hook": "blocks.0.attn.hook_result[0]", + "role": { + "tag": "AGGREGATOR", + "note": "Produces a sequence-length signal by counting tokens via the attention output width." + }, + "rasp_vars": [ + "length_helper" + ], + "labels": [ + "length_3_selector_width_attn_output" + ] + }, + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Computes the sequence length feature used to split the sequence into halves." + }, + "rasp_vars": [ + "length" + ], + "labels": [ + "length_3", + "length_3_selector_width_attn_output" + ] + }, + { + "id": "L1_MLP", + "hook": "blocks.1.mlp.hook_post", + "role": { + "tag": "COMBINER", + "note": "Builds a per-position mask indicating whether the position is in the first half." + }, + "rasp_vars": [ + "first_half_selector" + ], + "labels": [ + "first_half_selector_2" + ] + }, + { + "id": "L2_MLP", + "hook": "blocks.2.mlp.hook_post", + "role": { + "tag": "COMBINER", + "note": "Conditionally doubles elements in the first half using the first-half mask." + }, + "rasp_vars": [ + "double_first_half" + ], + "labels": [ + "double_first_half_1" + ] + } + ] +} diff --git a/annotations/case_46.json b/annotations/case_46.json new file mode 100644 index 0000000000000000000000000000000000000000..6096f9b783b83e8f3ba315b60151bf09c57d7d9f --- /dev/null +++ b/annotations/case_46.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_46", + "name": "decrement_by_1", + "summary": "Decrements each element in the sequence by 1.", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 1, + 3, + 1, + 5, + 3, + 7, + 5, + 0, + 2 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 3, + 0, + 6, + 4, + 0, + 3, + -1, + 8, + 4 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 9, + 9, + 6, + 3, + 2, + 6, + 6, + 1, + 4 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 7, + -1, + 9, + 9, + 8, + 1, + 5, + 2, + 7 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 5, + 2, + 9, + 6, + 3, + 5, + 8, + 1, + 5 + ] + } + ], + "is_categorical": true + }, + "program": "return rasp.Map(lambda x: x - 1, rasp.tokens).named('decrement')", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Adjusts each value by a fixed amount (subtracting 1) across the entire sequence." + }, + "rasp_vars": [ + "decrement" + ], + "labels": [ + "decrement_1" + ] + } + ] +} diff --git a/annotations/case_49.json b/annotations/case_49.json new file mode 100644 index 0000000000000000000000000000000000000000..f42e7556166c7239338227a111263961f0a49871 --- /dev/null +++ b/annotations/case_49.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_49", + "name": "decrement_to_multiple_of_three", + "summary": "Decrements each element in the sequence until it becomes a multiple of 3.", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 0, + 3, + 0, + 6, + 3, + 6, + 6, + 0, + 3 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 3, + 0, + 6, + 3, + 0, + 3, + 0, + 9, + 3 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 9, + 9, + 6, + 3, + 3, + 6, + 6, + 0, + 3 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 6, + 0, + 9, + 9, + 9, + 0, + 6, + 3, + 6 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 6, + 3, + 9, + 6, + 3, + 6, + 9, + 0, + 6 + ] + } + ], + "is_categorical": true + }, + "program": "decrement_to_multiple_of_three = rasp.Map(lambda x: x - (x % 3), rasp.tokens).named('decrement_to_multiple_of_three')\nreturn decrement_to_multiple_of_three", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Reduces each value to the nearest value that is a multiple of three." + }, + "rasp_vars": [ + "decrement_to_multiple_of_three" + ], + "labels": [ + "decrement_to_multiple_of_three_1" + ] + } + ] +} diff --git a/annotations/case_50.json b/annotations/case_50.json new file mode 100644 index 0000000000000000000000000000000000000000..0b6aa0c1fba73662b81ab7197930469d5afb7736 --- /dev/null +++ b/annotations/case_50.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_50", + "name": "hyperbolic_cosine", + "summary": "Applies the hyperbolic cosine to each element.", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 3.7621956910836314, + 27.308232836016487, + 3.7621956910836314, + 201.7156361224559, + 27.308232836016487, + 1490.479161252178, + 201.7156361224559, + 1.5430806348152437, + 10.067661995777765 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 27.308232836016487, + 1.5430806348152437, + 548.317035155212, + 74.20994852478785, + 1.5430806348152437, + 27.308232836016487, + 1.0, + 4051.5420254925943, + 74.20994852478785 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 11013.232920103324, + 11013.232920103324, + 548.317035155212, + 27.308232836016487, + 10.067661995777765, + 548.317035155212, + 548.317035155212, + 3.7621956910836314, + 74.20994852478785 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 1490.479161252178, + 1.0, + 11013.232920103324, + 11013.232920103324, + 4051.5420254925943, + 3.7621956910836314, + 201.7156361224559, + 10.067661995777765, + 1490.479161252178 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 201.7156361224559, + 10.067661995777765, + 11013.232920103324, + 548.317035155212, + 27.308232836016487, + 201.7156361224559, + 4051.5420254925943, + 3.7621956910836314, + 201.7156361224559 + ] + } + ], + "is_categorical": true + }, + "program": "return rasp.Map(math.cosh, rasp.tokens)", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Applies an elementwise hyperbolic cosine transformation to each input value." + }, + "rasp_vars": [ + "hyperbolic_cosine" + ], + "labels": [ + "map_1" + ] + } + ] +} diff --git a/annotations/case_51.json b/annotations/case_51.json new file mode 100644 index 0000000000000000000000000000000000000000..201dfbec4054689b2d9da1a1ec4d2597c9e228f8 --- /dev/null +++ b/annotations/case_51.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_51", + "name": "check_fibonacci", + "summary": "Checks if each element is a Fibonacci number", + "examples": [ + { + "input": [ + "BOS", + 74, + 87, + 99, + 23, + 2, + 21, + 52, + 1, + 87 + ], + "output": [ + "BOS", + 0, + 0, + 0, + 0, + 1, + 1, + 0, + 1, + 0 + ] + }, + { + "input": [ + "BOS", + 51, + 92, + 14, + 71, + 60, + 20, + 82, + 86, + 74 + ], + "output": [ + "BOS", + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + }, + { + "input": [ + "BOS", + 21, + 88, + 48, + 90, + 58, + 41, + 91, + 59, + 79 + ], + "output": [ + "BOS", + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + }, + { + "input": [ + "BOS", + 29, + 37, + 1, + 63, + 59, + 20, + 32, + 75, + 57 + ], + "output": [ + "BOS", + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0 + ] + }, + { + "input": [ + "BOS", + 14, + 61, + 61, + 46, + 61, + 50, + 54, + 63, + 2 + ], + "output": [ + "BOS", + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1 + ] + } + ], + "is_categorical": true + }, + "program": "fib_sequence = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]\ncheck_fibonacci_map = rasp.Map(lambda x: 1 if x in fib_sequence else 0, rasp.tokens).named(\"check_fibonacci_map\")\nreturn check_fibonacci_map", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "INDICATOR", + "note": "Marks each input element as Fibonacci or not using a fixed lookup set." + }, + "rasp_vars": [ + "check_fibonacci_map" + ], + "labels": [ + "check_fibonacci_map_1" + ] + } + ] +} diff --git a/annotations/case_52.json b/annotations/case_52.json new file mode 100644 index 0000000000000000000000000000000000000000..6626bee980c2e61d8725d50e28c708bf716506d9 --- /dev/null +++ b/annotations/case_52.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_52", + "name": "square_root", + "summary": "Apply square root to each token/value independently.", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 1.4142135623730951, + 2.0, + 1.4142135623730951, + 2.449489742783178, + 2.0, + 2.8284271247461903, + 2.449489742783178, + 1.0, + 1.7320508075688772 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 2.0, + 1.0, + 2.6457513110645907, + 2.23606797749979, + 1.0, + 2.0, + 0.0, + 3.0, + 2.23606797749979 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 3.1622776601683795, + 3.1622776601683795, + 2.6457513110645907, + 2.0, + 1.7320508075688772, + 2.6457513110645907, + 2.6457513110645907, + 1.4142135623730951, + 2.23606797749979 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 2.8284271247461903, + 0.0, + 3.1622776601683795, + 3.1622776601683795, + 3.0, + 1.4142135623730951, + 2.449489742783178, + 1.7320508075688772, + 2.8284271247461903 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 2.449489742783178, + 1.7320508075688772, + 3.1622776601683795, + 2.6457513110645907, + 2.0, + 2.449489742783178, + 3.0, + 1.4142135623730951, + 2.449489742783178 + ] + } + ], + "is_categorical": true + }, + "program": "return rasp.Map(lambda x: x ** 0.5, rasp.tokens).named(\"square_root\")", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Applies a per-position numeric map by computing the square root for each element." + }, + "rasp_vars": [ + "square_root" + ], + "labels": [ + "square_root_1" + ] + } + ] +} diff --git a/annotations/case_53.json b/annotations/case_53.json new file mode 100644 index 0000000000000000000000000000000000000000..36de8f0893f05fe943dc621d58df6ebce735f3a4 --- /dev/null +++ b/annotations/case_53.json @@ -0,0 +1,171 @@ +{ + "task": { + "id": "case_53", + "name": "increment_odd_indices", + "summary": "Increment elements at odd indices by 1", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 2, + 5, + 2, + 7, + 4, + 9, + 6, + 2, + 3 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 4, + 2, + 7, + 6, + 1, + 5, + 0, + 10, + 5 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 10, + 11, + 7, + 5, + 3, + 8, + 7, + 3, + 5 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 8, + 1, + 10, + 11, + 9, + 3, + 6, + 4, + 8 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 6, + 4, + 10, + 8, + 4, + 7, + 9, + 3, + 6 + ] + } + ], + "is_categorical": true + }, + "program": "odd_index_marker = rasp.Map(lambda x: x % 2, rasp.indices).named(\"odd_index_marker\")\nincremented_elements = rasp.SequenceMap(lambda elem, mark: elem + mark, rasp.tokens, odd_index_marker).named(\"incremented_elements\")\nreturn incremented_elements", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Computes the parity of each position's index (index mod 2) to produce a per-position binary value used as an increment signal." + }, + "rasp_vars": [ + "odd_index_marker" + ], + "labels": [ + "odd_index_marker_2" + ] + }, + { + "id": "L1_MLP", + "hook": "blocks.1.mlp.hook_post", + "role": { + "tag": "COMBINER", + "note": "Adds the odd-index marker to each element so only odd positions are incremented." + }, + "rasp_vars": [ + "incremented_elements" + ], + "labels": [ + "incremented_elements_1" + ] + } + ] +} diff --git a/annotations/case_54.json b/annotations/case_54.json new file mode 100644 index 0000000000000000000000000000000000000000..7fc5df9b9e83b4e21bf1780422326ff8837f6beb --- /dev/null +++ b/annotations/case_54.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_54", + "name": "hyperbolic_tangent", + "summary": "Applies the hyperbolic tangent to each element.", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 0.9640275800758169, + 0.999329299739067, + 0.9640275800758169, + 0.9999877116507956, + 0.999329299739067, + 0.9999997749296758, + 0.9999877116507956, + 0.7615941559557649, + 0.9950547536867305 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 0.999329299739067, + 0.7615941559557649, + 0.9999983369439447, + 0.9999092042625951, + 0.7615941559557649, + 0.999329299739067, + 0.0, + 0.999999969540041, + 0.9999092042625951 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 0.9999999958776927, + 0.9999999958776927, + 0.9999983369439447, + 0.999329299739067, + 0.9950547536867305, + 0.9999983369439447, + 0.9999983369439447, + 0.9640275800758169, + 0.9999092042625951 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 0.9999997749296758, + 0.0, + 0.9999999958776927, + 0.9999999958776927, + 0.999999969540041, + 0.9640275800758169, + 0.9999877116507956, + 0.9950547536867305, + 0.9999997749296758 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 0.9999877116507956, + 0.9950547536867305, + 0.9999999958776927, + 0.9999983369439447, + 0.999329299739067, + 0.9999877116507956, + 0.999999969540041, + 0.9640275800758169, + 0.9999877116507956 + ] + } + ], + "is_categorical": true + }, + "program": "return rasp.Map(math.tanh, rasp.tokens)", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Applies an elementwise hyperbolic tangent transformation to each input value." + }, + "rasp_vars": [ + "hyperbolic_tangent" + ], + "labels": [ + "map_1" + ] + } + ] +} diff --git a/annotations/case_55.json b/annotations/case_55.json new file mode 100644 index 0000000000000000000000000000000000000000..a612d91564fe01cd00f4e884c7724d6895a2f66b --- /dev/null +++ b/annotations/case_55.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_55", + "name": "hyperbolic_sine", + "summary": "Applies the hyperbolic sine to each element.", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 3.626860407847019, + 27.28991719712775, + 3.626860407847019, + 201.71315737027922, + 27.28991719712775, + 1490.4788257895502, + 201.71315737027922, + 1.1752011936438014, + 10.017874927409903 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 27.28991719712775, + 1.1752011936438014, + 548.3161232732465, + 74.20321057778875, + 1.1752011936438014, + 27.28991719712775, + 0.0, + 4051.54190208279, + 74.20321057778875 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 11013.232874703393, + 11013.232874703393, + 548.3161232732465, + 27.28991719712775, + 10.017874927409903, + 548.3161232732465, + 548.3161232732465, + 3.626860407847019, + 74.20321057778875 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 1490.4788257895502, + 0.0, + 11013.232874703393, + 11013.232874703393, + 4051.54190208279, + 3.626860407847019, + 201.71315737027922, + 10.017874927409903, + 1490.4788257895502 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 201.71315737027922, + 10.017874927409903, + 11013.232874703393, + 548.3161232732465, + 27.28991719712775, + 201.71315737027922, + 4051.54190208279, + 3.626860407847019, + 201.71315737027922 + ] + } + ], + "is_categorical": true + }, + "program": "hyperbolic_sine = rasp.Map(lambda x: math.sinh(x), rasp.tokens).named(\"hyperbolic_sine\")\nreturn hyperbolic_sine", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Applies an elementwise hyperbolic sine transformation to each input value." + }, + "rasp_vars": [ + "hyperbolic_sine" + ], + "labels": [ + "hyperbolic_sine_1" + ] + } + ] +} diff --git a/annotations/case_56.json b/annotations/case_56.json new file mode 100644 index 0000000000000000000000000000000000000000..7828ee997fa792599c4127139ee486d3cfd47a15 --- /dev/null +++ b/annotations/case_56.json @@ -0,0 +1,172 @@ +{ + "task": { + "id": "case_56", + "name": "zero_every_third", + "summary": "Sets every third element to zero.", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 2, + 4, + 0, + 6, + 4, + 0, + 6, + 1, + 0 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 4, + 1, + 0, + 5, + 1, + 0, + 0, + 9, + 0 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 10, + 10, + 0, + 4, + 3, + 0, + 7, + 2, + 0 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 8, + 0, + 0, + 10, + 9, + 0, + 6, + 3, + 0 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 6, + 3, + 0, + 7, + 4, + 0, + 9, + 2, + 0 + ] + } + ], + "is_categorical": true + }, + "program": "every_third = rasp.Map(lambda i: (i + 1) % 3 == 0, rasp.indices).named('every_third')\nevery_third_numerical = rasp.Map(lambda b: 1 if b else 0, every_third).named('every_third_numerical')\nresult_sequence = rasp.SequenceMap(lambda x, m: 0 if m == 1 else x, rasp.tokens, every_third_numerical).named('result_sequence')\nreturn result_sequence", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "INDICATOR", + "note": "Marks positions that should be zeroed out based on their place in the sequence." + }, + "rasp_vars": [ + "every_third", + "every_third_numerical" + ], + "labels": [ + "every_third_numerical_2" + ] + }, + { + "id": "L1_MLP", + "hook": "blocks.1.mlp.hook_post", + "role": { + "tag": "COMBINER", + "note": "Combines the input values with the position markers to produce the final masked sequence." + }, + "rasp_vars": [ + "result_sequence" + ], + "labels": [ + "result_sequence_1" + ] + } + ] +} diff --git a/annotations/case_58.json b/annotations/case_58.json new file mode 100644 index 0000000000000000000000000000000000000000..692ad148f0b574611e30eec12b497d6344cdf119 --- /dev/null +++ b/annotations/case_58.json @@ -0,0 +1,200 @@ +{ + "task": { + "id": "case_58", + "name": "mirror_first_half", + "summary": "Mirrors the first half of the sequence to the second half.", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 2.0, + 4.0, + 2.0, + 6.0, + 4.0, + 6.0, + 2.0, + 4.0, + 2.0 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 4.0, + 1.0, + 7.0, + 5.0, + 1.0, + 5.0, + 7.0, + 1.0, + 4.0 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 10.0, + 10.0, + 7.0, + 4.0, + 3.0, + 4.0, + 7.0, + 10.0, + 10.0 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 8.0, + 0.0, + 10.0, + 10.0, + 9.0, + 10.0, + 10.0, + 0.0, + 8.0 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 6.0, + 3.0, + 10.0, + 7.0, + 4.0, + 7.0, + 10.0, + 3.0, + 6.0 + ] + } + ], + "is_categorical": true + }, + "program": "all_true_selector = rasp.Select(rasp.tokens, rasp.tokens, rasp.Comparison.TRUE).named(\"all_true_selector\")\nlength = rasp.SelectorWidth(all_true_selector).named(\"length\")\nfirst_half_selector = rasp.Select(rasp.indices, rasp.Map(lambda x: x // 2, length), rasp.Comparison.LT).named(\"first_half_selector\")\nmirror_selector = rasp.Select(rasp.indices, rasp.SequenceMap(lambda x, l: l - 1 - x if x >= l // 2 else x, rasp.indices, length), rasp.Comparison.EQ).named(\"mirror_selector\")\nmirrored_sequence = rasp.Aggregate(mirror_selector, rasp.tokens, default=None).named(\"mirrored_sequence\")\nreturn mirrored_sequence", + "components": [ + { + "id": "L0H0_ATTN", + "hook": "blocks.0.attn.hook_result[0]", + "role": { + "tag": "AGGREGATOR", + "note": "Produces a sequence-length signal by counting tokens via the attention output width." + }, + "rasp_vars": [ + "all_true_selector" + ], + "labels": [ + "length_4_selector_width_attn_output" + ] + }, + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Converts the length-related signal into a sequence-length feature." + }, + "rasp_vars": [ + "length" + ], + "labels": [ + "length_4_selector_width_attn_output", + "length_4" + ] + }, + { + "id": "L1_MLP", + "hook": "blocks.1.mlp.hook_post", + "role": { + "tag": "COMBINER", + "note": "For each position, computes which source index should be copied so the second half mirrors the first half." + }, + "rasp_vars": [ + "mirror_selector" + ], + "labels": [ + "sequence_map_3" + ] + }, + { + "id": "L2H0_ATTN", + "hook": "blocks.2.attn.hook_result[0]", + "role": { + "tag": "ROUTER", + "note": "Moves values from the chosen source positions to form the mirrored output sequence." + }, + "rasp_vars": [ + "mirrored_sequence" + ], + "labels": [ + "mirrored_sequence_1" + ] + } + ] +} diff --git a/annotations/case_60.json b/annotations/case_60.json new file mode 100644 index 0000000000000000000000000000000000000000..685ae298fac205e93174ad80be1a3f4ffd552127 --- /dev/null +++ b/annotations/case_60.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_60", + "name": "increment", + "summary": "Increment each element in the sequence by 1.", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 3, + 5, + 3, + 7, + 5, + 9, + 7, + 2, + 4 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 5, + 2, + 8, + 6, + 2, + 5, + 1, + 10, + 6 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 11, + 11, + 8, + 5, + 4, + 8, + 8, + 3, + 6 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 9, + 1, + 11, + 11, + 10, + 3, + 7, + 4, + 9 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 7, + 4, + 11, + 8, + 5, + 7, + 10, + 3, + 7 + ] + } + ], + "is_categorical": true + }, + "program": "return rasp.Map(lambda x: x + 1, rasp.tokens).named(\"increment\")", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Applies elementwise increment of 1 to each token." + }, + "rasp_vars": [ + "increment" + ], + "labels": [ + "increment_1" + ] + } + ] +} diff --git a/annotations/case_62.json b/annotations/case_62.json new file mode 100644 index 0000000000000000000000000000000000000000..580da5ee9f8db5809788d1a5a1f2e9ad33e40e68 --- /dev/null +++ b/annotations/case_62.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_62", + "name": "factorial", + "summary": "Replaces each element with its factorial.", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 2, + 24, + 2, + 720, + 24, + 40320, + 720, + 1, + 6 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 24, + 1, + 5040, + 120, + 1, + 24, + 1, + 362880, + 120 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 3628800, + 3628800, + 5040, + 24, + 6, + 5040, + 5040, + 2, + 120 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 40320, + 1, + 3628800, + 3628800, + 362880, + 2, + 720, + 6, + 40320 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 720, + 6, + 3628800, + 5040, + 24, + 720, + 362880, + 2, + 720 + ] + } + ], + "is_categorical": true + }, + "program": "factorial = rasp.Map(lambda x: factorial_helper(x), rasp.tokens).named(\"factorial\")\nreturn factorial", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Transforms each input number into its corresponding factorial value." + }, + "rasp_vars": [ + "factorial" + ], + "labels": [ + "factorial_1" + ] + } + ] +} diff --git a/annotations/case_63.json b/annotations/case_63.json new file mode 100644 index 0000000000000000000000000000000000000000..0daeca2eaf4fd3634138d2d3fa492407306b3d91 --- /dev/null +++ b/annotations/case_63.json @@ -0,0 +1,171 @@ +{ + "task": { + "id": "case_63", + "name": "count_less_than", + "summary": "Replaces each element with the number of elements less than it in the sequence", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 1, + 4, + 1, + 6, + 4, + 8, + 6, + 0, + 3 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 3, + 1, + 7, + 5, + 1, + 3, + 0, + 8, + 5 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 7, + 7, + 4, + 2, + 1, + 4, + 4, + 0, + 3 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 4, + 0, + 7, + 7, + 6, + 1, + 3, + 2, + 4 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 3, + 1, + 8, + 6, + 2, + 3, + 7, + 0, + 3 + ] + } + ], + "is_categorical": true + }, + "program": "lt_selector = rasp.Select(rasp.tokens, rasp.tokens, rasp.Comparison.LT).named(\"lt_selector\")\ncount_lt = rasp.SelectorWidth(lt_selector).named(\"count_lt\")\nreturn count_lt", + "components": [ + { + "id": "L0H0_ATTN", + "hook": "blocks.0.attn.hook_result[0]", + "role": { + "tag": "AGGREGATOR", + "note": "For each position, gathers all tokens in the sequence that are smaller than the current token." + }, + "rasp_vars": [ + "lt_selector, count_lt" + ], + "labels": [ + "count_lt_1_selector_width_attn_output" + ] + }, + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Converts the gathered and summarized signal into the final number: how many tokens are smaller than the current token." + }, + "rasp_vars": [ + "count_lt" + ], + "labels": [ + "count_lt_1" + ] + } + ] +} diff --git a/annotations/case_64.json b/annotations/case_64.json new file mode 100644 index 0000000000000000000000000000000000000000..2746b0af1d32c7565f25bf43b4b794f76996f75e --- /dev/null +++ b/annotations/case_64.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_64", + "name": "cube_each_element", + "summary": "Cubes each element in the sequence.", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 8, + 64, + 8, + 216, + 64, + 512, + 216, + 1, + 27 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 64, + 1, + 343, + 125, + 1, + 64, + 0, + 729, + 125 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 1000, + 1000, + 343, + 64, + 27, + 343, + 343, + 8, + 125 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 512, + 0, + 1000, + 1000, + 729, + 8, + 216, + 27, + 512 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 216, + 27, + 1000, + 343, + 64, + 216, + 729, + 8, + 216 + ] + } + ], + "is_categorical": true + }, + "program": "cube_sequence = rasp.Map(lambda x: x ** 3, rasp.tokens).named('cube_sequence')\nreturn cube_sequence", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Computes the cube for each token value independently, applying element-wise exponentiation with no cross-position interaction." + }, + "rasp_vars": [ + "cube_sequence" + ], + "labels": [ + "cube_sequence_1" + ] + } + ] +} diff --git a/annotations/case_65.json b/annotations/case_65.json new file mode 100644 index 0000000000000000000000000000000000000000..fbcea2d2f7145f4f823ec341b7246434395fc60b --- /dev/null +++ b/annotations/case_65.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_65", + "name": "cube_root", + "summary": "Calculate the cube root of each element in the input sequence.", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 1.2599210498948732, + 1.5874010519681994, + 1.2599210498948732, + 1.8171205928321397, + 1.5874010519681994, + 2.0, + 1.8171205928321397, + 1.0, + 1.4422495703074083 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 1.5874010519681994, + 1.0, + 1.912931182772389, + 1.7099759466766968, + 1.0, + 1.5874010519681994, + 0.0, + 2.080083823051904, + 1.7099759466766968 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 2.154434690031884, + 2.154434690031884, + 1.912931182772389, + 1.5874010519681994, + 1.4422495703074083, + 1.912931182772389, + 1.912931182772389, + 1.2599210498948732, + 1.7099759466766968 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 2.0, + 0.0, + 2.154434690031884, + 2.154434690031884, + 2.080083823051904, + 1.2599210498948732, + 1.8171205928321397, + 1.4422495703074083, + 2.0 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 1.8171205928321397, + 1.4422495703074083, + 2.154434690031884, + 1.912931182772389, + 1.5874010519681994, + 1.8171205928321397, + 2.080083823051904, + 1.2599210498948732, + 1.8171205928321397 + ] + } + ], + "is_categorical": true + }, + "program": "cube_root_operation = rasp.Map(lambda x: x ** (1 / 3) if x >= 0 else -(-x) ** (1 / 3), rasp.tokens).named(\"cube_root_operation\")\nreturn cube_root_operation", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Applies a cube-root transform to each element independently." + }, + "rasp_vars": [ + "cube_root_operation" + ], + "labels": [ + "cube_root_operation_1" + ] + } + ] +} diff --git a/annotations/case_66.json b/annotations/case_66.json new file mode 100644 index 0000000000000000000000000000000000000000..de057e2f7672d5194268487e4ca4029bcc86cbdc --- /dev/null +++ b/annotations/case_66.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_66", + "name": "round", + "summary": "Round each element in the input sequence to the nearest integer.", + "examples": [ + { + "input": [ + "BOS", + 4.25, + 2.0, + 0.25, + 4.75, + 3.5, + 1.5, + 2.75, + 1.75, + 3.5 + ], + "output": [ + "BOS", + 4, + 2, + 0, + 5, + 4, + 2, + 3, + 2, + 4 + ] + }, + { + "input": [ + "BOS", + 0.5, + 1.0, + 4.5, + 1.5, + 2.0, + 1.5, + 4.25, + 0.75, + 3.25 + ], + "output": [ + "BOS", + 1, + 1, + 5, + 2, + 2, + 2, + 4, + 1, + 3 + ] + }, + { + "input": [ + "BOS", + 1.5, + 4.75, + 3.5, + 2.5, + 1.75, + 1.5, + 4.5, + 2.5, + 2.5 + ], + "output": [ + "BOS", + 2, + 5, + 4, + 3, + 2, + 2, + 5, + 3, + 3 + ] + }, + { + "input": [ + "BOS", + 0.75, + 1.75, + 0.5, + 0.25, + 2.75, + 1.25, + 0.25, + 0.0, + 2.75 + ], + "output": [ + "BOS", + 1, + 2, + 1, + 0, + 3, + 1, + 0, + 0, + 3 + ] + }, + { + "input": [ + "BOS", + 2.75, + 4.0, + 2.25, + 3.75, + 3.5, + 3.5, + 4.5, + 2.75, + 4.75 + ], + "output": [ + "BOS", + 3, + 4, + 2, + 4, + 4, + 4, + 5, + 3, + 5 + ] + } + ], + "is_categorical": true + }, + "program": "shift_for_rounding = rasp.Map(lambda x: x + 0.5, rasp.tokens).named(\"shift_for_rounding\")\nrounded_sequence = rasp.Map(lambda x: int(x), shift_for_rounding).named(\"rounded_sequence\")\nreturn rounded_sequence", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Rounds each element to the nearest integer via an elementwise transform." + }, + "rasp_vars": [ + "rounded_sequence" + ], + "labels": [ + "rounded_sequence_1" + ] + } + ] +} diff --git a/annotations/case_67.json b/annotations/case_67.json new file mode 100644 index 0000000000000000000000000000000000000000..33624df8c86ce78e3b6bda87c6414517c31d877c --- /dev/null +++ b/annotations/case_67.json @@ -0,0 +1,186 @@ +{ + "task": { + "id": "case_67", + "name": "multiply_by_length", + "summary": "Multiply each element of the sequence by the length of the sequence.", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 18, + 36, + 18, + 54, + 36, + 72, + 54, + 9, + 27 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 36, + 9, + 63, + 45, + 9, + 36, + 0, + 81, + 45 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 90, + 90, + 63, + 36, + 27, + 63, + 63, + 18, + 45 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 72, + 0, + 90, + 90, + 81, + 18, + 54, + 27, + 72 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 54, + 27, + 90, + 63, + 36, + 54, + 81, + 18, + 54 + ] + } + ], + "is_categorical": true + }, + "program": "all_true_selector = rasp.Select(rasp.tokens, rasp.tokens, rasp.Comparison.TRUE).named(\"all_true_selector\")\nlength_sequence = rasp.SelectorWidth(all_true_selector).named(\"length_sequence\")\nmultiply_by_length_sequence = rasp.SequenceMap(lambda x, y: x * y, rasp.tokens, length_sequence).named(\"multiply_by_length_sequence\")\nreturn multiply_by_length_sequence", + "components": [ + { + "id": "L0H0_ATTN", + "hook": "blocks.0.attn.hook_result[0]", + "role": { + "tag": "AGGREGATOR", + "note": "Uniformly attends to all positions and aggregates them into a per-position count of total sequence length." + }, + "rasp_vars": [ + "all_true_selector" + ], + "labels": [ + "length_sequence_2_selector_width_attn_output" + ] + }, + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Computes a per-position representation of the sequence length from the aggregation." + }, + "rasp_vars": [ + "length_sequence" + ], + "labels": [ + "length_sequence_2", + "length_sequence_2_selector_width_attn_output" + ] + }, + { + "id": "L1_MLP", + "hook": "blocks.1.mlp.hook_post", + "role": { + "tag": "COMBINER", + "note": "Multiplies each input element by the computed sequence length." + }, + "rasp_vars": [ + "multiply_by_length_sequence" + ], + "labels": [ + "multiply_by_length_sequence_1" + ] + } + ] +} diff --git a/annotations/case_68.json b/annotations/case_68.json new file mode 100644 index 0000000000000000000000000000000000000000..bea53e68a3c1d85b34993c61260ae762e580623d --- /dev/null +++ b/annotations/case_68.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_68", + "name": "increment_to_multiple_of_three", + "summary": "Increment each element until it becomes a multiple of 3.", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 3, + 6, + 3, + 6, + 6, + 9, + 6, + 3, + 3 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 6, + 3, + 9, + 6, + 3, + 6, + 0, + 9, + 6 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 12, + 12, + 9, + 6, + 3, + 9, + 9, + 3, + 6 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 9, + 0, + 12, + 12, + 9, + 3, + 6, + 3, + 9 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 6, + 3, + 12, + 9, + 6, + 6, + 9, + 3, + 6 + ] + } + ], + "is_categorical": true + }, + "program": "increment_to_multiple_of_three = rasp.Map(lambda x: x + (3 - (x % 3)) % 3, rasp.tokens).named(\"increment_to_multiple_of_three\")\nreturn increment_to_multiple_of_three", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Increments each value by the amount needed to reach the next valid multiple of three." + }, + "rasp_vars": [ + "increment_to_multiple_of_three" + ], + "labels": [ + "increment_to_multiple_of_three_1" + ] + } + ] +} diff --git a/annotations/case_69.json b/annotations/case_69.json new file mode 100644 index 0000000000000000000000000000000000000000..2428dd48ec92cd73f741468eec84ce1336516a0c --- /dev/null +++ b/annotations/case_69.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_69", + "name": "sign", + "summary": "Assign -1, 0, or 1 to each element of the input sequence based on its sign.", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 1, + 1, + 1, + 1, + 1, + 1, + 0, + 1, + 1 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 1, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ] + } + ], + "is_categorical": true + }, + "program": "def sign_check(x):\n if x < 0:\n return -1\n elif x > 0:\n return 1\n else:\n return 0\n\nreturn rasp.Map(sign_check, rasp.tokens).named(\"sign\")", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Applies a sign function elementwise to map each number to {-1, 0, 1}." + }, + "rasp_vars": [ + "sign" + ], + "labels": [ + "sign_1" + ] + } + ] +} diff --git a/annotations/case_7.json b/annotations/case_7.json new file mode 100644 index 0000000000000000000000000000000000000000..f2b6f63d973f7827c5e75c4a8ee5d7ad817c589f --- /dev/null +++ b/annotations/case_7.json @@ -0,0 +1,171 @@ +{ + "task": { + "id": "case_7", + "name": "make_hist", + "summary": "Returns the number of times each token occurs in the input.", + "examples": [ + { + "input": [ + "BOS", + "b", + "b", + "a", + "a", + "b", + "b", + "a", + "a", + "a" + ], + "output": [ + "BOS", + 4, + 4, + 5, + 5, + 4, + 4, + 5, + 5, + 5 + ] + }, + { + "input": [ + "BOS", + "c", + "c", + "a", + "c", + "a", + "c", + "c", + "a", + "a" + ], + "output": [ + "BOS", + 5, + 5, + 4, + 5, + 4, + 5, + 5, + 4, + 4 + ] + }, + { + "input": [ + "BOS", + "c", + "a", + "c", + "c", + "a", + "a", + "c", + "b", + "c" + ], + "output": [ + "BOS", + 5, + 3, + 5, + 5, + 3, + 3, + 5, + 1, + 5 + ] + }, + { + "input": [ + "BOS", + "c", + "c", + "c", + "b", + "c", + "b", + "b", + "c", + "b" + ], + "output": [ + "BOS", + 5, + 5, + 5, + 4, + 5, + 4, + 4, + 5, + 4 + ] + }, + { + "input": [ + "BOS", + "c", + "c", + "c", + "a", + "c", + "b", + "a", + "b", + "b" + ], + "output": [ + "BOS", + 4, + 4, + 4, + 2, + 4, + 3, + 2, + 3, + 3 + ] + } + ], + "is_categorical": true + }, + "program": "same_tok = rasp.Select(rasp.tokens, rasp.tokens, rasp.Comparison.EQ).named(\"same_tok\")\nreturn rasp.SelectorWidth(same_tok).named(\"hist\")", + "components": [ + { + "id": "L0H0_ATTN", + "hook": "blocks.0.attn.hook_result[0]", + "role": { + "tag": "AGGREGATOR", + "note": "Groups each position with all positions that contain the same token and summarizes 'how many matches' that token has across the sequence" + }, + "rasp_vars": [ + "same_tok" + ], + "labels": [ + "hist_1_selector_width_attn_output" + ] + }, + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Converts that summary signal into the final value: the total number of times the token at each position appears in the input." + }, + "rasp_vars": [ + "hist" + ], + "labels": [ + "hist_1" + ] + } + ] +} diff --git a/annotations/case_70.json b/annotations/case_70.json new file mode 100644 index 0000000000000000000000000000000000000000..d1ffa9cd38b1df0f0e1bdd070735bd0cb178da7d --- /dev/null +++ b/annotations/case_70.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_70", + "name": "cosine", + "summary": "Apply the cosine function to each element of the input sequence.", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + -0.4161468365471424, + -0.6536436208636119, + -0.4161468365471424, + 0.960170286650366, + -0.6536436208636119, + -0.14550003380861354, + 0.960170286650366, + 0.5403023058681398, + -0.9899924966004454 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + -0.6536436208636119, + 0.5403023058681398, + 0.7539022543433046, + 0.28366218546322625, + 0.5403023058681398, + -0.6536436208636119, + 1.0, + -0.9111302618846769, + 0.28366218546322625 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + -0.8390715290764524, + -0.8390715290764524, + 0.7539022543433046, + -0.6536436208636119, + -0.9899924966004454, + 0.7539022543433046, + 0.7539022543433046, + -0.4161468365471424, + 0.28366218546322625 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + -0.14550003380861354, + 1.0, + -0.8390715290764524, + -0.8390715290764524, + -0.9111302618846769, + -0.4161468365471424, + 0.960170286650366, + -0.9899924966004454, + -0.14550003380861354 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 0.960170286650366, + -0.9899924966004454, + -0.8390715290764524, + 0.7539022543433046, + -0.6536436208636119, + 0.960170286650366, + -0.9111302618846769, + -0.4161468365471424, + 0.960170286650366 + ] + } + ], + "is_categorical": true + }, + "program": "return rasp.Map(lambda x: math.cos(x), rasp.tokens).named(\"apply_cosine\")", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Applies an elementwise cosine transformation to each input element independently." + }, + "rasp_vars": [ + "cosine" + ], + "labels": [ + "apply_cosine_1" + ] + } + ] +} diff --git a/annotations/case_71.json b/annotations/case_71.json new file mode 100644 index 0000000000000000000000000000000000000000..4df837029cf07ecc0326ddd24d1e5898b0c2bcb0 --- /dev/null +++ b/annotations/case_71.json @@ -0,0 +1,185 @@ +{ + "task": { + "id": "case_71", + "name": "divide_by_length", + "summary": "Divide each element by the length of the sequence", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 0.2222222222222222, + 0.4444444444444444, + 0.2222222222222222, + 0.6666666666666666, + 0.4444444444444444, + 0.8888888888888888, + 0.6666666666666666, + 0.1111111111111111, + 0.3333333333333333 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 0.4444444444444444, + 0.1111111111111111, + 0.7777777777777778, + 0.5555555555555556, + 0.1111111111111111, + 0.4444444444444444, + 0.0, + 1.0, + 0.5555555555555556 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 1.1111111111111112, + 1.1111111111111112, + 0.7777777777777778, + 0.4444444444444444, + 0.3333333333333333, + 0.7777777777777778, + 0.7777777777777778, + 0.2222222222222222, + 0.5555555555555556 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 0.8888888888888888, + 0.0, + 1.1111111111111112, + 1.1111111111111112, + 1.0, + 0.2222222222222222, + 0.6666666666666666, + 0.3333333333333333, + 0.8888888888888888 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 0.6666666666666666, + 0.3333333333333333, + 1.1111111111111112, + 0.7777777777777778, + 0.4444444444444444, + 0.6666666666666666, + 1.0, + 0.2222222222222222, + 0.6666666666666666 + ] + } + ], + "is_categorical": true + }, + "program": "all_true_selector = rasp.Select(rasp.tokens, rasp.tokens, rasp.Comparison.TRUE).named(\"all_true_selector\"); length = rasp.SelectorWidth(all_true_selector).named(\"length\"); divided_by_length = rasp.SequenceMap(lambda x, length: x / length if length > 0 else 0, rasp.tokens, length).named(\"divided_by_length\"); return divided_by_length", + "components": [ + { + "id": "L0H0_ATTN", + "hook": "blocks.0.attn.hook_result[0]", + "role": { + "tag": "AGGREGATOR", + "note": "Uniformly attends to all positions and aggregates them into a per-position count of total sequence length." + }, + "rasp_vars": [ + "all_true_selector" + ], + "labels": [ + "length_2_selector_width_attn_output" + ] + }, + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Computes a per-position representation of the sequence length from the aggregation." + }, + "rasp_vars": [ + "length" + ], + "labels": [ + "length_2, length_2_selector_width_attn_output" + ] + }, + { + "id": "L1_MLP", + "hook": "blocks.1.mlp.hook_post", + "role": { + "tag": "COMBINER", + "note": "Normalizes each token value by the sequence length to produce the final output." + }, + "rasp_vars": [ + "divided_by_length" + ], + "labels": [ + "divided_by_length_1" + ] + } + ] +} diff --git a/annotations/case_72.json b/annotations/case_72.json new file mode 100644 index 0000000000000000000000000000000000000000..cca8dc3c7fd3c11fb809cb49d0c3c3d1e1aeffce --- /dev/null +++ b/annotations/case_72.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_72", + "name": "negation", + "summary": "Negate each element in the input sequence.", + "examples": [ + { + "input": [ + "BOS", + 7, + -2, + -9, + 9, + 4, + -4, + 1, + -3, + 4 + ], + "output": [ + "BOS", + -7, + 2, + 9, + -9, + -4, + 4, + -1, + 3, + -4 + ] + }, + { + "input": [ + "BOS", + -8, + -6, + 8, + -4, + -2, + -4, + 7, + -7, + 3 + ], + "output": [ + "BOS", + 8, + 6, + -8, + 4, + 2, + 4, + -7, + 7, + -3 + ] + }, + { + "input": [ + "BOS", + -4, + 9, + 4, + 0, + -3, + -4, + 8, + 0, + 0 + ], + "output": [ + "BOS", + 4, + -9, + -4, + 0, + 3, + 4, + -8, + 0, + 0 + ] + }, + { + "input": [ + "BOS", + -7, + -3, + -8, + -9, + 1, + -5, + -9, + -10, + 1 + ], + "output": [ + "BOS", + 7, + 3, + 8, + 9, + -1, + 5, + 9, + 10, + -1 + ] + }, + { + "input": [ + "BOS", + 1, + 6, + -1, + 5, + 4, + 4, + 8, + 1, + 9 + ], + "output": [ + "BOS", + -1, + -6, + 1, + -5, + -4, + -4, + -8, + -1, + -9 + ] + } + ], + "is_categorical": true + }, + "program": "negation_function = lambda x: -x\nnegated_sequence = rasp.Map(negation_function, rasp.tokens).named(\"negated_sequence\")\nreturn negated_sequence", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Applies element-wise negation to each token value." + }, + "rasp_vars": [ + "negated_sequence" + ], + "labels": [ + "negated_sequence_1" + ] + } + ] +} diff --git a/annotations/case_73.json b/annotations/case_73.json new file mode 100644 index 0000000000000000000000000000000000000000..35b7b14c7b08b2fb5f015db7305e9dce18f28e50 --- /dev/null +++ b/annotations/case_73.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_73", + "name": "sine", + "summary": "Apply the sine function to each element of the input sequence.", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 0.9092974268256817, + -0.7568024953079282, + 0.9092974268256817, + -0.27941549819892586, + -0.7568024953079282, + 0.9893582466233818, + -0.27941549819892586, + 0.8414709848078965, + 0.1411200080598672 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + -0.7568024953079282, + 0.8414709848078965, + 0.6569865987187891, + -0.9589242746631385, + 0.8414709848078965, + -0.7568024953079282, + 0.0, + 0.4121184852417566, + -0.9589242746631385 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + -0.5440211108893698, + -0.5440211108893698, + 0.6569865987187891, + -0.7568024953079282, + 0.1411200080598672, + 0.6569865987187891, + 0.6569865987187891, + 0.9092974268256817, + -0.9589242746631385 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 0.9893582466233818, + 0.0, + -0.5440211108893698, + -0.5440211108893698, + 0.4121184852417566, + 0.9092974268256817, + -0.27941549819892586, + 0.1411200080598672, + 0.9893582466233818 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + -0.27941549819892586, + 0.1411200080598672, + -0.5440211108893698, + 0.6569865987187891, + -0.7568024953079282, + -0.27941549819892586, + 0.4121184852417566, + 0.9092974268256817, + -0.27941549819892586 + ] + } + ], + "is_categorical": true + }, + "program": "sine = rasp.Map(lambda x: math.sin(x), rasp.tokens).named('sine')\nreturn sine", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Applies an elementwise sine transformation independently to each input element." + }, + "rasp_vars": [ + "sine" + ], + "labels": [ + "sine_1" + ] + } + ] +} diff --git a/annotations/case_75.json b/annotations/case_75.json new file mode 100644 index 0000000000000000000000000000000000000000..97043c5c337ab7b07a2786b48e2e60bf610cc9ee --- /dev/null +++ b/annotations/case_75.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_75", + "name": "double_elements", + "summary": "Double each element of the input sequence.", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 4, + 8, + 4, + 12, + 8, + 16, + 12, + 2, + 6 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 8, + 2, + 14, + 10, + 2, + 8, + 0, + 18, + 10 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 20, + 20, + 14, + 8, + 6, + 14, + 14, + 4, + 10 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 16, + 0, + 20, + 20, + 18, + 4, + 12, + 6, + 16 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 12, + 6, + 20, + 14, + 8, + 12, + 18, + 4, + 12 + ] + } + ], + "is_categorical": true + }, + "program": "double_elements = rasp.Map(lambda x: x * 2, rasp.tokens).named(\"double_elements\")\nreturn double_elements", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Doubles each input element independently to produce the output sequence." + }, + "rasp_vars": [ + "double_elements" + ], + "labels": [ + "double_elements_1" + ] + } + ] +} diff --git a/annotations/case_77.json b/annotations/case_77.json new file mode 100644 index 0000000000000000000000000000000000000000..903edafb0d4d406cef884072bbfa4f42e87d8aab --- /dev/null +++ b/annotations/case_77.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_77", + "name": "tangent", + "summary": "Apply the tangent function to each element of the sequence.", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + -2.185039863261519, + 1.1578212823495775, + -2.185039863261519, + -0.29100619138474915, + 1.1578212823495775, + -6.799711455220379, + -0.29100619138474915, + 1.5574077246549023, + -0.1425465430742778 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 1.1578212823495775, + 1.5574077246549023, + 0.8714479827243188, + -3.380515006246586, + 1.5574077246549023, + 1.1578212823495775, + 0.0, + -0.45231565944180985, + -3.380515006246586 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 0.6483608274590866, + 0.6483608274590866, + 0.8714479827243188, + 1.1578212823495775, + -0.1425465430742778, + 0.8714479827243188, + 0.8714479827243188, + -2.185039863261519, + -3.380515006246586 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + -6.799711455220379, + 0.0, + 0.6483608274590866, + 0.6483608274590866, + -0.45231565944180985, + -2.185039863261519, + -0.29100619138474915, + -0.1425465430742778, + -6.799711455220379 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + -0.29100619138474915, + -0.1425465430742778, + 0.6483608274590866, + 0.8714479827243188, + 1.1578212823495775, + -0.29100619138474915, + -0.45231565944180985, + -2.185039863261519, + -0.29100619138474915 + ] + } + ], + "is_categorical": true + }, + "program": "return rasp.Map(lambda x: math.tan(x), rasp.tokens).named(\"tangent\")", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Applies an elementwise tangent transformation to each input element." + }, + "rasp_vars": [ + "tangent" + ], + "labels": [ + "tangent_1" + ] + } + ] +} diff --git a/annotations/case_79.json b/annotations/case_79.json new file mode 100644 index 0000000000000000000000000000000000000000..4d17068a37c80aee1d5e2bff30a464da16bd57f7 --- /dev/null +++ b/annotations/case_79.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_79", + "name": "check_prime", + "summary": "Check if each number in a sequence is prime", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 1, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 1 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 0, + 0, + 1, + 1, + 0, + 0, + 0, + 0, + 1 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 0, + 0, + 1, + 0, + 1, + 1, + 1, + 1, + 1 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 1, + 0 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 0, + 1, + 0, + 1, + 0, + 0, + 0, + 1, + 0 + ] + } + ], + "is_categorical": true + }, + "program": "return rasp.Map(lambda x: primecheck(x), rasp.tokens)", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "INDICATOR", + "note": "Outputs a binary flag indicating whether each input element is prime." + }, + "rasp_vars": [ + "is_prime" + ], + "labels": [ + "map_1" + ] + } + ] +} diff --git a/annotations/case_8.json b/annotations/case_8.json new file mode 100644 index 0000000000000000000000000000000000000000..54d83d7f9285ffda6da406d634970a7870c54325 --- /dev/null +++ b/annotations/case_8.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_8", + "name": "identity", + "summary": "Returns each element of the input sequence unchanged", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ] + } + ], + "is_categorical": true + }, + "program": "return rasp.Map(lambda x: x, rasp.tokens)", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Applies the identity function to each input element, leaving them unchanged." + }, + "rasp_vars": [ + "identity" + ], + "labels": [ + "map_1" + ] + } + ] +} diff --git a/annotations/case_80.json b/annotations/case_80.json new file mode 100644 index 0000000000000000000000000000000000000000..97d7d33122f3f66d551864495e0a5d5de07735b9 --- /dev/null +++ b/annotations/case_80.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_80", + "name": "subtract_constant", + "summary": "Subtract a constant from each element of the input sequence.", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 0, + 2, + 0, + 4, + 2, + 6, + 4, + -1, + 1 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 2, + -1, + 5, + 3, + -1, + 2, + -2, + 7, + 3 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 8, + 8, + 5, + 2, + 1, + 5, + 5, + 0, + 3 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 6, + -2, + 8, + 8, + 7, + 0, + 4, + 1, + 6 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 4, + 1, + 8, + 5, + 2, + 4, + 7, + 0, + 4 + ] + } + ], + "is_categorical": true + }, + "program": "subtract_constant = rasp.Map(lambda x: x - constant, rasp.tokens).named(f\"subtract_{constant}\")\nreturn subtract_constant", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Applies a fixed constant subtraction to each input element." + }, + "rasp_vars": [ + "subtract_constant" + ], + "labels": [ + "subtract_2_1" + ] + } + ] +} diff --git a/annotations/case_82.json b/annotations/case_82.json new file mode 100644 index 0000000000000000000000000000000000000000..f084a2d600b4b234c2b4b2d544fe45dc8e2c51b8 --- /dev/null +++ b/annotations/case_82.json @@ -0,0 +1,214 @@ +{ + "task": { + "id": "case_82", + "name": "halve_second_half", + "summary": "Halve the elements in the second half of the sequence.", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 2, + 4, + 2, + 6, + 2.0, + 4.0, + 3.0, + 0.5, + 1.5 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 4, + 1, + 7, + 5, + 0.5, + 2.0, + 0.0, + 4.5, + 2.5 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 10, + 10, + 7, + 4, + 1.5, + 3.5, + 3.5, + 1.0, + 2.5 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 8, + 0, + 10, + 10, + 4.5, + 1.0, + 3.0, + 1.5, + 4.0 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 6, + 3, + 10, + 7, + 2.0, + 3.0, + 4.5, + 1.0, + 3.0 + ] + } + ], + "is_categorical": true + }, + "program": "all_true_selector = rasp.Select(rasp.tokens, rasp.tokens, rasp.Comparison.TRUE).named(\"all_true_selector\"); length = rasp.SelectorWidth(all_true_selector).named(\"length\"); half_length = rasp.Map(lambda x: x // 2, length).named(\"half_length\"); in_second_half = rasp.SequenceMap(lambda idx, half: idx >= half, rasp.indices, half_length).named(\"in_second_half\"); halved_sequence = rasp.SequenceMap(lambda x, cond: x / 2 if cond else x, rasp.tokens, in_second_half).named(\"halved_sequence\"); return halved_sequence", + "components": [ + { + "id": "L0H0_ATTN", + "hook": "blocks.0.attn.hook_result[0]", + "role": { + "tag": "AGGREGATOR", + "note": "Produces a shared sequence-length signal used to locate where the second half starts." + }, + "rasp_vars": [ + "all_true_selector" + ], + "labels": [ + "length_4_selector_width_attn_output" + ] + }, + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Converts the length-related signal into a sequence-length feature." + }, + "rasp_vars": [ + "length" + ], + "labels": [ + "length_4", + "length_4_selector_width_attn_output " + ] + }, + { + "id": "L1_MLP", + "hook": "blocks.1.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Computes the halfway point of the sequence from the length feature." + }, + "rasp_vars": [ + "half_length" + ], + "labels": [ + "half_length_3" + ] + }, + { + "id": "L2_MLP", + "hook": "blocks.2.mlp.hook_post", + "role": { + "tag": "COMBINER", + "note": "Creates a per-position mask indicating whether a position is in the second half." + }, + "rasp_vars": [ + "in_second_half" + ], + "labels": [ + "in_second_half_2" + ] + }, + { + "id": "L3_MLP", + "hook": "blocks.3.mlp.hook_post", + "role": { + "tag": "COMBINER", + "note": "Applies halving only where the second-half mask is true, otherwise leaves values unchanged." + }, + "rasp_vars": [ + "halved_sequence" + ], + "labels": [ + "halved_sequence_1" + ] + } + ] +} diff --git a/annotations/case_83.json b/annotations/case_83.json new file mode 100644 index 0000000000000000000000000000000000000000..f752c246316a75f1f7bc64e12cbaf126d5c1b2e2 --- /dev/null +++ b/annotations/case_83.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_83", + "name": "triple_sequence", + "summary": "Triple each element in the sequence.", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 6, + 12, + 6, + 18, + 12, + 24, + 18, + 3, + 9 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 12, + 3, + 21, + 15, + 3, + 12, + 0, + 27, + 15 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 30, + 30, + 21, + 12, + 9, + 21, + 21, + 6, + 15 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 24, + 0, + 30, + 30, + 27, + 6, + 18, + 9, + 24 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 18, + 9, + 30, + 21, + 12, + 18, + 27, + 6, + 18 + ] + } + ], + "is_categorical": true + }, + "program": "triple_sequence = rasp.Map(lambda x: x * 3, rasp.tokens).named(\"triple_sequence\")\nreturn triple_sequence", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Applies an elementwise multiplication of 3 to each input element." + }, + "rasp_vars": [ + "triple_sequence" + ], + "labels": [ + "triple_sequence_1" + ] + } + ] +} diff --git a/annotations/case_84.json b/annotations/case_84.json new file mode 100644 index 0000000000000000000000000000000000000000..6d99b8ed8760c9718f915b1cf3e1d028de9c9e6e --- /dev/null +++ b/annotations/case_84.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_84", + "name": "arctangent", + "summary": "Apply the arctangent function to each element of the input sequence.", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 1.1071487177940904, + 1.3258176636680326, + 1.1071487177940904, + 1.4056476493802699, + 1.3258176636680326, + 1.446441332248135, + 1.4056476493802699, + 0.7853981633974483, + 1.2490457723982544 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 1.3258176636680326, + 0.7853981633974483, + 1.4288992721907328, + 1.373400766945016, + 0.7853981633974483, + 1.3258176636680326, + 0.0, + 1.460139105621001, + 1.373400766945016 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 1.4711276743037347, + 1.4711276743037347, + 1.4288992721907328, + 1.3258176636680326, + 1.2490457723982544, + 1.4288992721907328, + 1.4288992721907328, + 1.1071487177940904, + 1.373400766945016 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 1.446441332248135, + 0.0, + 1.4711276743037347, + 1.4711276743037347, + 1.460139105621001, + 1.1071487177940904, + 1.4056476493802699, + 1.2490457723982544, + 1.446441332248135 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 1.4056476493802699, + 1.2490457723982544, + 1.4711276743037347, + 1.4288992721907328, + 1.3258176636680326, + 1.4056476493802699, + 1.460139105621001, + 1.1071487177940904, + 1.4056476493802699 + ] + } + ], + "is_categorical": true + }, + "program": "arctangent = rasp.Map(lambda x: math.atan(x), rasp.tokens).named(\"arctangent\")\nreturn arctangent", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Applies the arctangent transformation independently to each element." + }, + "rasp_vars": [ + "arctangent" + ], + "labels": [ + "arctangent_1" + ] + } + ] +} diff --git a/annotations/case_85.json b/annotations/case_85.json new file mode 100644 index 0000000000000000000000000000000000000000..5c07caf50606336a5835e960055299b346c48175 --- /dev/null +++ b/annotations/case_85.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_85", + "name": "square_each_element", + "summary": "Square each element of the input sequence.", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 4, + 16, + 4, + 36, + 16, + 64, + 36, + 1, + 9 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 16, + 1, + 49, + 25, + 1, + 16, + 0, + 81, + 25 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 100, + 100, + 49, + 16, + 9, + 49, + 49, + 4, + 25 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 64, + 0, + 100, + 100, + 81, + 4, + 36, + 9, + 64 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 36, + 9, + 100, + 49, + 16, + 36, + 81, + 4, + 36 + ] + } + ], + "is_categorical": true + }, + "program": "square_each_element = rasp.Map(lambda x: x ** 2, rasp.tokens).named(\"square_each_element\")\nreturn square_each_element", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Squares each input element independently." + }, + "rasp_vars": [ + "square_each_element" + ], + "labels": [ + "square_each_element_1" + ] + } + ] +} diff --git a/annotations/case_86.json b/annotations/case_86.json new file mode 100644 index 0000000000000000000000000000000000000000..7537565ebf412b8658226d7024048caf62351d8d --- /dev/null +++ b/annotations/case_86.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_86", + "name": "check_power_of_2", + "summary": "Check if each element is a power of 2. Return 1 if true, otherwise 0.", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 1, + 1, + 1, + 0, + 1, + 1, + 0, + 0, + 0 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 1, + 0 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 1 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 1, + 0 + ] + } + ], + "is_categorical": true + }, + "program": "return rasp.Map(lambda x: pow_of_n(n=2, x=x), rasp.tokens).named(\"check_multiple_of_2\")", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "INDICATOR", + "note": "Applies a per-element test indicating whether each input element is a power of 2." + }, + "rasp_vars": [ + "check_power_of_2" + ], + "labels": [ + "check_multiple_of_2_1" + ] + } + ] +} diff --git a/annotations/case_87.json b/annotations/case_87.json new file mode 100644 index 0000000000000000000000000000000000000000..1369e20c10b77289e84d3468ce3bf93d294f6eb8 --- /dev/null +++ b/annotations/case_87.json @@ -0,0 +1,158 @@ +{ + "task": { + "id": "case_87", + "name": "binarize", + "summary": "Binarize a sequence of integers using a threshold.", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 0, + 1, + 0, + 1, + 1, + 1, + 1, + 0, + 1 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 1, + 0, + 1, + 1, + 0, + 1, + 0, + 1, + 1 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 0, + 1 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 1, + 0, + 1, + 1, + 1, + 0, + 1, + 1, + 1 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 0, + 1 + ] + } + ], + "is_categorical": true + }, + "program": "compare_to_threshold = rasp.Map(lambda x: x >= threshold, rasp.tokens)\nbinarized_sequence = rasp.Map(lambda x: 1 if x else 0, compare_to_threshold)\nreturn binarized_sequence", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "INDICATOR", + "note": "Computes a per-token binary output by thresholding each integer." + }, + "rasp_vars": [ + "compare_to_threshold", + "binarized_sequence" + ], + "labels": [ + "map_1" + ] + } + ] +} diff --git a/annotations/case_90.json b/annotations/case_90.json new file mode 100644 index 0000000000000000000000000000000000000000..02fa7efa316225db52022968597c8faefe1f927f --- /dev/null +++ b/annotations/case_90.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_90", + "name": "token_replacer", + "summary": "Replaces a specific token with another one.", + "examples": [ + { + "input": [ + "BOS", + "findme", + "TPSI", + "no", + "V", + "findme", + "poiVg", + "LB", + "findme", + "no" + ], + "output": [ + "BOS", + "-", + "TPSI", + "no", + "V", + "-", + "poiVg", + "LB", + "-", + "no" + ] + }, + { + "input": [ + "BOS", + "LB", + "findme", + "TPSI", + "oCLrZaW", + "LB", + "V", + "LB", + "findme", + "V" + ], + "output": [ + "BOS", + "LB", + "-", + "TPSI", + "oCLrZaW", + "LB", + "V", + "LB", + "-", + "V" + ] + }, + { + "input": [ + "BOS", + "b", + "J", + "V", + "-", + "poiVg", + "b", + "oCLrZaW", + "-", + "poiVg" + ], + "output": [ + "BOS", + "b", + "J", + "V", + "-", + "poiVg", + "b", + "oCLrZaW", + "-", + "poiVg" + ] + }, + { + "input": [ + "BOS", + "V", + "TPSI", + "no", + "no", + "LB", + "b", + "V", + "J", + "no" + ], + "output": [ + "BOS", + "V", + "TPSI", + "no", + "no", + "LB", + "b", + "V", + "J", + "no" + ] + }, + { + "input": [ + "BOS", + "oCLrZaW", + "findme", + "J", + "TPSI", + "oCLrZaW", + "J", + "poiVg", + "oCLrZaW", + "poiVg" + ], + "output": [ + "BOS", + "oCLrZaW", + "-", + "J", + "TPSI", + "oCLrZaW", + "J", + "poiVg", + "oCLrZaW", + "poiVg" + ] + } + ], + "is_categorical": true + }, + "program": "replaced = rasp.Map(lambda x: replacement if x == target else x, sop)\nreturn replaced", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Outputs the replacement token when the input matches the target, otherwise passes the token through." + }, + "rasp_vars": [ + "replaced" + ], + "labels": [ + "map_1" + ] + } + ] +} diff --git a/annotations/case_91.json b/annotations/case_91.json new file mode 100644 index 0000000000000000000000000000000000000000..9809fa0147f339fc8d5936d09c30f2dd0785448b --- /dev/null +++ b/annotations/case_91.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_91", + "name": "apply_threshold", + "summary": "Set all values below a threshold to 0", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 0, + 4, + 0, + 6, + 4, + 8, + 6, + 0, + 3 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 4, + 0, + 7, + 5, + 0, + 4, + 0, + 9, + 5 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 0, + 5 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 0, + 6, + 3, + 8 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 0, + 6 + ] + } + ], + "is_categorical": true + }, + "program": "apply_threshold_operation = rasp.Map(lambda x: 0 if x < threshold else x, rasp.tokens).named(\"apply_threshold\")\nreturn apply_threshold_operation", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Applies a thresholding transform per element. Values below the threshold are replaced with 0." + }, + "rasp_vars": [ + "apply_threshold_operation" + ], + "labels": [ + "apply_threshold_1" + ] + } + ] +} diff --git a/annotations/case_93.json b/annotations/case_93.json new file mode 100644 index 0000000000000000000000000000000000000000..47aed19dde0205c91cc1c754219e4d8d0b11c890 --- /dev/null +++ b/annotations/case_93.json @@ -0,0 +1,199 @@ +{ + "task": { + "id": "case_93", + "name": "swap_odd_index", + "summary": "Swaps the nth with the n+1th element if n%2==1.", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 2.0, + 2.0, + 4.0, + 4.0, + 6.0, + 6.0, + 8.0, + 3.0, + 1.0 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 4.0, + 7.0, + 1.0, + 1.0, + 5.0, + 0.0, + 4.0, + 5.0, + 9.0 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 10.0, + 7.0, + 10.0, + 3.0, + 4.0, + 7.0, + 7.0, + 5.0, + 2.0 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 8.0, + 10.0, + 0.0, + 9.0, + 10.0, + 6.0, + 2.0, + 8.0, + 3.0 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 6.0, + 10.0, + 3.0, + 4.0, + 7.0, + 9.0, + 6.0, + 6.0, + 2.0 + ] + } + ], + "is_categorical": true + }, + "program": "len = rasp.SelectorWidth(rasp.Select(rasp.indices, rasp.indices, rasp.Comparison.TRUE))\nswaper = rasp.SequenceMap(\n lambda x, y: x if (x == y - 1 and y % 2 == 0 or x == 0) else (x - 1 if (x + 1) % 2 == 1 else x + 1),\n rasp.indices,\n len)\nswap_selector = rasp.Select(rasp.indices, swaper, rasp.Comparison.EQ)\nswaped = rasp.Aggregate(swap_selector, rasp.tokens)\nreturn swaped", + "components": [ + { + "id": "L0H0_ATTN", + "hook": "blocks.0.attn.hook_result[0]", + "role": { + "tag": "AGGREGATOR", + "note": "Produces an all-positions counting signal that supports deriving the sequence length." + }, + "rasp_vars": [ + "length_helper" + ], + "labels": [ + "selector_width_4_selector_width_attn_output" + ] + }, + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Computes the sequence length feature from the helper counting signal." + }, + "rasp_vars": [ + "len" + ], + "labels": [ + "selector_width_4, selector_width_4_selector_width_attn_output " + ] + }, + { + "id": "L1_MLP", + "hook": "blocks.1.mlp.hook_post", + "role": { + "tag": "COMBINER", + "note": "Builds the per-position target index to swap with, based on the current index and sequence length." + }, + "rasp_vars": [ + "swaper" + ], + "labels": [ + "sequence_map_3" + ] + }, + { + "id": "L2H0_ATTN", + "hook": "blocks.2.attn.hook_result[0]", + "role": { + "tag": "ROUTER", + "note": "Moves tokens so that every odd index takes the next token and every even index (except the first) takes the previous token, producing the swapped output." + }, + "rasp_vars": [ + "swaped" + ], + "labels": [ + "aggregate_1" + ] + } + ] +} diff --git a/annotations/case_95.json b/annotations/case_95.json new file mode 100644 index 0000000000000000000000000000000000000000..5db3dbad4f8ba20593fe68fc51eff389b68bc5ef --- /dev/null +++ b/annotations/case_95.json @@ -0,0 +1,157 @@ +{ + "task": { + "id": "case_95", + "name": "count_distinct_prime_factors", + "summary": "Counts the distinct prime factors of each number in the input list.", + "examples": [ + { + "input": [ + "BOS", + 6, + 19, + 28, + 14, + 10, + 7, + 28, + 20, + 6 + ], + "output": [ + "BOS", + 2, + 1, + 2, + 2, + 2, + 1, + 2, + 2, + 2 + ] + }, + { + "input": [ + "BOS", + 25, + 18, + 22, + 10, + 10, + 23, + 20, + 3, + 7 + ], + "output": [ + "BOS", + 1, + 2, + 2, + 2, + 2, + 1, + 2, + 1, + 1 + ] + }, + { + "input": [ + "BOS", + 24, + 16, + 26, + 26, + 9, + 27, + 27, + 15, + 14 + ], + "output": [ + "BOS", + 2, + 1, + 2, + 2, + 1, + 1, + 1, + 2, + 2 + ] + }, + { + "input": [ + "BOS", + 1, + 27, + 20, + 0, + 11, + 25, + 21, + 28, + 11 + ], + "output": [ + "BOS", + 0, + 1, + 2, + 0, + 1, + 1, + 2, + 2, + 1 + ] + }, + { + "input": [ + "BOS", + 23, + 2, + 21, + 20, + 1, + 23, + 11, + 29, + 5 + ], + "output": [ + "BOS", + 1, + 1, + 2, + 2, + 0, + 1, + 1, + 1, + 1 + ] + } + ], + "is_categorical": true + }, + "program": "def count_prime_factors(n):\n if n == 0: return 0\n\n count = 0\n if n % 2 == 0:\n count += 1\n while n % 2 == 0:\n n //= 2\n\n factor = 3\n while factor * factor <= n:\n if n % factor == 0:\n count += 1\n while n % factor == 0:\n n //= factor\n factor += 2\n\n if n > 2:\n count += 1\n return count\n\nprime_factor_counts = rasp.Map(count_prime_factors, rasp.tokens).named(\"prime_factor_counts\")\nreturn prime_factor_counts", + "components": [ + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Applies a per-number computation that outputs the count of distinct prime factors." + }, + "rasp_vars": [ + "prime_factor_counts" + ], + "labels": [ + "map_1" + ] + } + ] +} diff --git a/annotations/case_97.json b/annotations/case_97.json new file mode 100644 index 0000000000000000000000000000000000000000..5d42f991f21c3b93fa182fcaddf86b032ce94186 --- /dev/null +++ b/annotations/case_97.json @@ -0,0 +1,231 @@ +{ + "task": { + "id": "case_97", + "name": "scale_by_max", + "summary": "Scale a sequence by its maximum element.", + "examples": [ + { + "input": [ + "BOS", + 2, + 4, + 2, + 6, + 4, + 8, + 6, + 1, + 3 + ], + "output": [ + "BOS", + 0.25, + 0.5, + 0.25, + 0.75, + 0.5, + 1.0, + 0.75, + 0.125, + 0.375 + ] + }, + { + "input": [ + "BOS", + 4, + 1, + 7, + 5, + 1, + 4, + 0, + 9, + 5 + ], + "output": [ + "BOS", + 0.4444444444444444, + 0.1111111111111111, + 0.7777777777777778, + 0.5555555555555556, + 0.1111111111111111, + 0.4444444444444444, + 0.0, + 1.0, + 0.5555555555555556 + ] + }, + { + "input": [ + "BOS", + 10, + 10, + 7, + 4, + 3, + 7, + 7, + 2, + 5 + ], + "output": [ + "BOS", + 1.0, + 1.0, + 0.7, + 0.4, + 0.3, + 0.7, + 0.7, + 0.2, + 0.5 + ] + }, + { + "input": [ + "BOS", + 8, + 0, + 10, + 10, + 9, + 2, + 6, + 3, + 8 + ], + "output": [ + "BOS", + 0.8, + 0.0, + 1.0, + 1.0, + 0.9, + 0.2, + 0.6, + 0.3, + 0.8 + ] + }, + { + "input": [ + "BOS", + 6, + 3, + 10, + 7, + 4, + 6, + 9, + 2, + 6 + ], + "output": [ + "BOS", + 0.6, + 0.3, + 1.0, + 0.7, + 0.4, + 0.6, + 0.9, + 0.2, + 0.6 + ] + } + ], + "is_categorical": true + }, + "program": "length = rasp.SelectorWidth(rasp.Select(rasp.tokens, rasp.tokens, rasp.Comparison.TRUE)).named('length')\nleq_count_selector = rasp.Select(rasp.tokens, rasp.tokens, rasp.Comparison.LEQ).named('leq_count_selector')\nleq_count = rasp.SelectorWidth(leq_count_selector).named('leq_count')\nmax_pos_selector = rasp.Select(leq_count, length, rasp.Comparison.EQ).named('max_pos_selector')\nmax_element = rasp.Aggregate(max_pos_selector, rasp.tokens).named('max_element')\nscale_by_max_sequence = rasp.SequenceMap(lambda x, m: (x / m) if m > 0 else 0, rasp.tokens, max_element).named('scale_by_max_sequence')\nreturn scale_by_max_sequence", + "components": [ + { + "id": "L0H0_ATTN", + "hook": "blocks.0.attn.hook_result[0]", + "role": { + "tag": "AGGREGATOR", + "note": "Produces a shared sequence-level size signal used to identify the maximum element." + }, + "rasp_vars": [ + "length" + ], + "labels": [ + "length_5_selector_width_attn_output" + ] + }, + { + "id": "L0_MLP", + "hook": "blocks.0.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Converts the length-related signal into the sequence-length feature." + }, + "rasp_vars": [ + "length" + ], + "labels": [ + "length_5_selector_width_attn_output", + "length_5", + "sequence_map_8" + ] + }, + { + "id": "L1H0_ATTN", + "hook": "blocks.1.attn.hook_result[0]", + "role": { + "tag": "AGGREGATOR", + "note": "For each element, summarizes how it compares against all other elements in the sequence to support finding the maximum." + }, + "rasp_vars": [ + "leq_count_selector" + ], + "labels": [ + "leq_count_4_selector_width_attn_output" + ] + }, + { + "id": "L1_MLP", + "hook": "blocks.1.mlp.hook_post", + "role": { + "tag": "MAPPER", + "note": "Post-processes the LEQ comparison aggregation signal into a per-position count of how many elements are less than or equal to the current token." + }, + "rasp_vars": [ + "leq_count", + "max_pos_selector" + ], + "labels": [ + "leq_count_4_selector_width_attn_output", + "leq_count_4" + ] + }, + { + "id": "L2H0_ATTN", + "hook": "blocks.2.attn.hook_result[0]", + "role": { + "tag": "AGGREGATOR", + "note": "Extracts the maximum value and makes it available as a shared reference for every position." + }, + "rasp_vars": [ + "max_element" + ], + "labels": [ + "max_element_2" + ] + }, + { + "id": "L2_MLP", + "hook": "blocks.2.mlp.hook_post", + "role": { + "tag": "COMBINER", + "note": "Produces the final scaled values by scaling each element using the shared maximum reference." + }, + "rasp_vars": [ + "scale_by_max_sequence" + ], + "labels": [ + "scale_by_max_sequence_1" + ] + } + ] +} diff --git a/real_circuits/llama3_abc_annotations.json b/real_circuits/llama3_abc_annotations.json new file mode 100644 index 0000000000000000000000000000000000000000..2cfa183922bb7e60ae905442bb80cca0c04d9a11 --- /dev/null +++ b/real_circuits/llama3_abc_annotations.json @@ -0,0 +1,117 @@ +{ + "task": { + "id": "llama3_8b_abc", + "name": "A+B+C arithmetic", + "summary": "Three-operand addition. The model receives a prompt of the form \"A + B + C = \"", + "model": "meta-llama/Meta-Llama-3-8B", + "examples": [ + {"prompt": "23 + 17 + 19 = ", "answer": "59"}, + {"prompt": "42 + 31 + 26 = ", "answer": "99"}, + {"prompt": "58 + 14 + 33 = ", "answer": "105"}, + {"prompt": "71 + 12 + 45 = ", "answer": "128"}, + {"prompt": "16 + 27 + 38 = ", "answer": "81"} + ] + }, + "components": [ + { + "id": "L15H3_ATTN", + "hook": "blocks.15.attn.hook_z", + "layer": 15, + "head": 3, + "role": { + "note": "Primary C-transfer head. At the final query position, this head selectively reads the third operand C and writes C-dependent information into the last-token residual stream. Its C edge is the load-bearing route. Corrupt-C patching moves the answer logits toward the C-corrupted answer, but this head alone does not fully overwrite the final prediction.", + "additional_note": "Last survivor of iterative head pruning over layers 15-16. Single-head ablation in isolation drops accuracy 1.000 -> 0.758. Paper Fig. 5 shows it attends from the last token to the third operand C, routing C's value into the residual at the '=' position." + } + }, + { + "id": "L15H13_ATTN", + "hook": "blocks.15.attn.hook_z", + "layer": 15, + "head": 13, + "role": { + "note": "Primary B-transfer head. At the final query position, this head selectively reads the second operand B and transfers B-dependent information into the last-token residual stream. Corrupt-B patching through this head strongly shifts the model toward the B-corrupted answer.", + "additional_note": "Operand-transfer head at Layer 15. Second-to-last survivor of iterative head pruning. Paper Fig. 5 states that this head attends from the last token to the second operand B." + } + }, + { + "id": "L15H31_ATTN", + "hook": "blocks.15.attn.hook_z", + "layer": 15, + "head": 31, + "role": { + "note": "Backup C-transfer head. In the full circuit this head is mostly redundant with L15H3, but when L15H3 is suppressed it becomes strongly load-bearing. Its functional route is last-token attention to the third operand C, providing an auxiliary C-transfer pathway.", + "additional_note": "Secondary transfer head at Layer 15. It is not catastrophic alone but in the critical tail. Paper Table. 4 lists it in the secondary AF1 transfer set." + } + }, + { + "id": "L16H1_ATTN", + "hook": "blocks.16.attn.hook_z", + "layer": 16, + "head": 1, + "role": { + "note": "Tertiary C-transfer backup head. This head carries C-related signal through its last-token attention to the third operand, but it becomes clearly load-bearing only after the stronger C-transfer routes L15H3 and L15H31 are suppressed. Its output is less cleanly helpful in the full circuit, suggesting a mixed or context-dependent C-support role.", + "additional_note": "Backup (Tertiary) C-Transfer head at Layer 16. Present in the localized attention heads list in the Paper Tab. 4." + } + }, + { + "id": "L16H21_ATTN", + "hook": "blocks.16.attn.hook_z", + "layer": 16, + "head": 21, + "role": { + "note": "Primary A-transfer head. At the final query position, this head selectively reads the first operand A and transfers A-dependent information into the last-token residual stream. Corrupt-A patching through this head almost completely redirects the model toward the A-corrupted answer.", + "additional_note": "A-Operand transfer head at L=16. Paper Fig. 5 states that it attends from the last token to the first operand A; the model effectively cannot solve A+B+C without it." + } + }, + { + "id": "L20_MLP", + "hook": "blocks.20.hook_mlp_out", + "layer": 20, + "head": null, + "role": { + "note": "L20 MLP writes a latent arithmetic feature that depends on all operands. Its last-token output is useful for the arithmetic task and depends on the operands, but it does not directly write the final answer or a clean intermediate such as A+B/B+C. Downstream layers appear to use this latent feature to form the final answer direction.", + "additional_note": "L20 is the retained representative of the graded L17-L21 causal MLP block. Direct zero-ablation drops acc 1.0 to 0.737. Corrupt-operand patching gives balanced flip rates across A/B/C (0.253/0.242/0.273) with corrupt-answer logit gains +2.03/+2.20/+2.31, showing that the output carries operand-dependent task signal without isolating a specific arithmetic operation (i.e. it does not do any intermediate A+B or A+C or B+C type calculation). L20 is better described as a latent feature-builder." + } + }, + { + "id": "L29_MLP", + "hook": "blocks.29.hook_mlp_out", + "layer": 29, + "head": null, + "role": { + "note": "L29 MLP's output points toward the correct answer in projection tests, but is not needed by itself in the full circuit. Directly removing or mean ablating L29 MLP does not reduce accuracy, so its answer-related signal is best described as redundant with other computation.", + "additional_note": "L29 is retained as a disagreement case between attribution methods. Evidence for answer-related output: candidate-target logit lens has answer top-5 = 0.394 while pair-sum and operand targets stay near zero; Evidence against isolated necessity: direct zero-ablation leaves accuracy unchanged." + } + }, + { + "id": "L31_MLP", + "hook": "blocks.31.hook_mlp_out", + "layer": 31, + "head": null, + "role": { + "note": "L31 MLP's output strongly points toward the correct answer in projection tests, but this projection is not answer-specific. The true answer gets a high logit, but operands and pair sums also receive high mean logits. Directly removing or mean ablating L31 barely changes accuracy, so its signal is redundant in the full circuit.", + "additional_note": "L31 is retained as the clearest lens-positive but causally redundant MLP. It has the strongest single-MLP answer lens signal (answer top-5 = 0.566), at the same time, isolated direct zero-ablation barely changes accuracy, and corrupt-operand patching produces zero flips for A/B/C. Its high mean logits for answer, pair sums, and individual operands suggest broad final-logit amplification rather than a clean arithmetic operation." + } + }, + { + "id": "L26H3_ATTN", + "hook": "blocks.26.attn.hook_z", + "layer": 26, + "head": 3, + "role": { + "note": "L26H3 attention head's output points toward the correct answer in projection tests, but its attention mostly goes to the token rather than the operand tokens. Removing this head does not reduce accuracy, so this answer-related signal is not needed by itself in the full circuit.", + "additional_note": "L26H3 is a paper-named BOS-attention-sink case. Evidence for answer-related output: per-head logit lens ranks it 2/480 over layers 17-31, with top-1 = 0.162 and top-3 = 0.394. Evidence that it is not reading operands: at the last query position, attention mass is BOS = 0.587 and operand sum A+B+C = 0.027. Evidence against isolated necessity: when L26H3 and the other high-lens late attention heads are zeroed cumulatively, accuracy remains 1.0, including after L26H3 is removed. This matches the paper's Sec. 4.5 and Appendix A.4 claim that these answer-predicting heads show a BOS-sink pattern rather than an interpretable operand-reading pattern." + } + }, + { + "id": "L28H18_ATTN", + "hook": "blocks.28.attn.hook_z", + "layer": 28, + "head": 18, + "role": { + "note": "L28H18 attention head's output is the strongest late-attention projection toward the correct answer, but its attention is mostly on and positional tokens rather than operands. Removing it does not reduce accuracy, so this answer-related signal is not needed by itself in the full circuit.", + "additional_note": "L28H18 is the strongest paper-named late-attention lens hit. Evidence for answer-related output: per-head logit lens ranks it 1/480 over layers 17-31. Evidence that it is not primarily reading operands: at the last query position, attention mass is BOS = 0.445 and operand sum A+B+C = 0.102. The remaining non-BOS mass is concentrated more on positional anchors such as '=' than on operands. Evidence against isolated necessity: when L28H18 and the other high-lens late attention heads are zeroed cumulatively, accuracy remains 1.0, including after L28H18 is removed. This matches the paper's Sec. 4.5 and Appendix A.4 claim that these answer-predicting heads show a BOS-sink pattern rather than an interpretable operand-reading pattern." + } + } + ] +}