Antik Khan
Add annotations
3d3ae36
Raw
History Blame Contribute Delete
3.77 kB
{
"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"
]
}
]
}